@@ -25,7 +25,7 @@ module ModelTCP (
25
25
26
26
import Control.Exception (assert )
27
27
import Data.Aeson
28
- import Data.Foldable as Foldable (Foldable (sum ))
28
+ import Data.Foldable as Foldable (Foldable (sum , toList ))
29
29
import Data.List.NonEmpty (NonEmpty ((:|) ))
30
30
import qualified Data.List.NonEmpty as NE
31
31
import Data.PQueue.Prio.Min (MinPQueue )
@@ -181,9 +181,10 @@ forecastTcpMsgSend
181
181
tcpstate0
182
182
now0
183
183
msgsize0 =
184
- let (forecasts, tcpstate) = trySend [] tcpstate0 now0 msgsize0
185
- overallforecast = sconcat forecasts
186
- in (overallforecast, mergeAdjacentForecasts forecasts, tcpstate)
184
+ let (forecasts, ! tcpstate) = trySend [] tcpstate0 now0 msgsize0
185
+ ! mergedForecasts = mergeAdjacentForecasts forecasts
186
+ ! overallforecast = sconcat mergedForecasts
187
+ in (overallforecast, toList mergedForecasts, tcpstate)
187
188
where
188
189
trySend ::
189
190
[TcpMsgForecast ] ->
@@ -340,9 +341,11 @@ forecastTcpMsgSend
340
341
341
342
-- | To make the result easier to interpret, merge together any fragments
342
343
-- that are in fact contiguous.
343
- mergeAdjacentForecasts :: NonEmpty TcpMsgForecast -> [ TcpMsgForecast ]
344
+ mergeAdjacentForecasts :: NonEmpty TcpMsgForecast -> NonEmpty TcpMsgForecast
344
345
mergeAdjacentForecasts (forecast0 :| forecasts0) =
345
- go forecast0 forecasts0
346
+ case go forecast0 forecasts0 of
347
+ [] -> error " internal: merged into empty"
348
+ (x : xs) -> x :| xs
346
349
where
347
350
go forecast (forecast' : forecasts)
348
351
| msgSendTrailingEdge forecast == msgSendLeadingEdge forecast' =
0 commit comments