Skip to content

Commit 7d0e755

Browse files
committed
fixup: avoid IntMap.intersection for common case
The common case is that no TX has been downloaded.
1 parent 4e77c23 commit 7d0e755

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

  • ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V2

ouroboros-network/lib/Ouroboros/Network/TxSubmission/Inbound/V2/State.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,12 @@ mkPeerActionContext now policy peeraddr peerState sharedState =
9292

9393
-- Remove downloaded tx bodies that are no longer in the shared state.
9494
peerState' =
95-
peerState {
96-
peerDownloadedTxs = IntMap.restrictKeys (peerDownloadedTxs peerState) (IntMap.keysSet (sharedTxTable sharedState'))
97-
}
95+
let downloaded = peerDownloadedTxs peerState
96+
in if IntMap.null downloaded
97+
then peerState
98+
else peerState {
99+
peerDownloadedTxs = IntMap.intersection downloaded (sharedTxTable sharedState')
100+
}
98101

99102
sharedPeerState' =
100103
case Map.lookup peeraddr (sharedPeers sharedState') of

0 commit comments

Comments
 (0)