Repository navigation
Commit 4e27abc
committed
Match first argument strictly in Put (*>) and (<>) and use B.append
In Data.Binary.Put, pattern-match the first argument strictly in (*>)
and mappend' while keeping the second argument lazy (preserving infinite
streaming Put such as 'let go = putWord8 1 <> go' and 'mapM_ put [1..]'),
and use Data.Binary.Builder.append directly instead of Monoid.mappend.
This eliminates the intermediate Builder thunk on the left-hand side of
every (<>) / (>>) without breaking Safe Haskell or lazy streaming.
Benchmarks (GHC 9.10.3, tasty-bench +RTS -T, vs parent commit npqmvlxx):
- wasm/generic/encode Module: 2.04 ms -> 1.81 ms (-12%), 15 MB -> 13 MB alloc
- generics-bench (Cabal24 enc): 1.38 ms -> 1.34 ms (same), 9.2 MB -> 8.2 MB alloc (-11%)
- pcap/encode & pcap/generic: 2.2 MB -> 2.1 MB / 4.0 MB -> 3.9 MB alloc (same time)
Assisted-By: Antigravity (Gemini 4)1 parent c189cf3 commit 4e27abc
1 file changed
Lines changed: 7 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
164 | 163 | | |
165 | 164 | | |
166 | 165 | | |
| |||
0 commit comments