Skip to content

Commit 90e892c

Browse files
committed
simulation: squash some minor thunks
1 parent f659eda commit 90e892c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

simulation/src/LeiosProtocol/Relay.hs

+8-7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
{-# LANGUAGE OverloadedRecordDot #-}
1515
{-# LANGUAGE PolyKinds #-}
1616
{-# LANGUAGE RankNTypes #-}
17+
{-# LANGUAGE RecordWildCards #-}
1718
{-# LANGUAGE ScopedTypeVariables #-}
1819
{-# LANGUAGE StandaloneDeriving #-}
1920
{-# LANGUAGE StandaloneKindSignatures #-}
@@ -440,16 +441,16 @@ relayProducer config sst = TC.Yield MsgInit $ idle initRelayProducerLocalState
440441
when (expand.value == 0 && (isBlocking blocking || shrink.value == 0)) $ do
441442
throw $ RequestedNoChange (isBlocking blocking) shrink expand
442443
-- Shrink the window:
443-
let keptValues = Seq.drop (fromIntegral shrink) lst.window
444+
let !keptValues = Seq.drop (fromIntegral shrink) lst.window
444445
-- Find the new entries:
445446
newEntries <- readNewEntries sst blocking expand lst.lastTicket
446447
-- Expand the window:
447-
let newValues = Seq.fromList [(e.key, e.ticket) | e <- Foldable.toList newEntries]
448+
let newValues = Seq.fromList [(key, ticket) | RB.EntryWithTicket{..} <- Foldable.toList newEntries]
448449
let window' = keptValues <> newValues
449450
let lastTicket' = case newValues of
450451
Seq.Empty -> lst.lastTicket
451452
_ Seq.:|> (_, ticket) -> ticket
452-
let lst' = lst{window = window', lastTicket = lastTicket'}
453+
let !lst' = lst{window = window', lastTicket = lastTicket'}
453454
let responseList = fmap (fst . (.value)) newEntries
454455
-- Yield the new entries:
455456
withSingIBlockingStyle blocking $ do
@@ -547,7 +548,7 @@ runRelayConsumer config sst chan =
547548
-- implementation.
548549
type RelayConsumerLocalState :: Type -> Type -> Type -> N -> Type
549550
data RelayConsumerLocalState id header body n = RelayConsumerLocalState
550-
{ pendingRequests :: Nat n
551+
{ pendingRequests :: !(Nat n)
551552
, pendingExpand :: !WindowExpand
552553
-- ^ The number of headers that we have requested but
553554
-- which have not yet been replied to. We need to track this it keep
@@ -711,7 +712,7 @@ relayConsumerPipelined config sst =
711712
-- It's important not to pipeline more requests for headers when we
712713
-- have no bodies to ask for, since (with no other guard) this will
713714
-- put us into a busy-polling loop.
714-
let lst' = lst0{pendingRequests = pendingRequests'}
715+
let !lst' = lst0{pendingRequests = pendingRequests'}
715716

716717
-- Note: the peer will proceed with only one of the two
717718
-- arguments of Collect, depending on whether responses are
@@ -720,7 +721,7 @@ relayConsumerPipelined config sst =
720721
Left lst -> do
721722
-- In this case there is nothing else to do so we block until we
722723
-- collect a reply.
723-
let lst' = lst{pendingRequests = pendingRequests'}
724+
let !lst' = lst{pendingRequests = pendingRequests'}
724725
return $ TS.Collect Nothing (handleResponse lst')
725726

726727
done ::
@@ -783,7 +784,7 @@ relayConsumerPipelined config sst =
783784
else do
784785
let available2 = Map.withoutKeys lst.available idsToRequestSet
785786
modifyTVar' sst.inFlightVar $ Set.union idsToRequestSet
786-
let !lst2 = lst{pendingRequests = Succ lst.pendingRequests, available = available2}
787+
let !lst2 = lst{pendingRequests = Succ $! lst.pendingRequests, available = available2}
787788
return $
788789
TS.YieldPipelined
789790
(MsgRequestBodies idsToRequest)

0 commit comments

Comments
 (0)