Commit e29d4d3
* flate: read the bufio decode path via Peek instead of per-byte ReadByte
huffmanBufioReader filled the bit buffer with fr.ReadByte() once per input
byte. bufio.Reader.ReadByte does not inline, so each call is a barrier that
spills the fill loop's fb/fnb registers -- roughly 1.85x slower than the
*bytes.Reader variant, whose ReadByte inlines to a slice index.
Read from a Peek window instead: peek bufio's buffered slice and index it
directly (pbuf[pos]), refilling when drained. Peek only views the buffer, so
consumed bytes are Discard()ed before every return, keeping the reader
position correct for nextBlock/moreBits and the gzip trailer. peekBufio
refills from at most one underlying Read (never Peek(Size()), which would
block a streaming/sync writer until the whole buffer fills).
Only the *bufio.Reader variant changes; the other four generated variants
are byte-identical.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* flate: drop stray blank lines in the generated read sites
The $GETBYTE_E$ placeholder started with a newline the template already
supplied, so every read site picked up a blank line before its return --
25 in total, and across all five variants rather than only the bufio one.
With that fixed the four non-bufio variants are byte-identical to the stock
generated output again (verified by diffing each generated function).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent c0bbc84 commit e29d4d3
3 files changed
Lines changed: 225 additions & 68 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
74 | | - | |
75 | | - | |
| 73 | + | |
76 | 74 | | |
77 | | - | |
78 | | - | |
| 75 | + | |
79 | 76 | | |
80 | 77 | | |
81 | 78 | | |
| |||
88 | 85 | | |
89 | 86 | | |
90 | 87 | | |
91 | | - | |
| 88 | + | |
92 | 89 | | |
93 | 90 | | |
94 | 91 | | |
| |||
108 | 105 | | |
109 | 106 | | |
110 | 107 | | |
111 | | - | |
| 108 | + | |
112 | 109 | | |
113 | 110 | | |
114 | 111 | | |
115 | 112 | | |
116 | 113 | | |
117 | 114 | | |
118 | 115 | | |
119 | | - | |
| 116 | + | |
120 | 117 | | |
121 | 118 | | |
122 | 119 | | |
| |||
127 | 124 | | |
128 | 125 | | |
129 | 126 | | |
130 | | - | |
131 | | - | |
132 | | - | |
| 127 | + | |
133 | 128 | | |
134 | 129 | | |
135 | 130 | | |
136 | 131 | | |
137 | | - | |
138 | | - | |
| 132 | + | |
139 | 133 | | |
140 | 134 | | |
141 | 135 | | |
| |||
144 | 138 | | |
145 | 139 | | |
146 | 140 | | |
147 | | - | |
| 141 | + | |
148 | 142 | | |
149 | 143 | | |
150 | 144 | | |
| |||
155 | 149 | | |
156 | 150 | | |
157 | 151 | | |
158 | | - | |
159 | | - | |
160 | | - | |
| 152 | + | |
161 | 153 | | |
162 | 154 | | |
163 | 155 | | |
164 | 156 | | |
165 | | - | |
166 | | - | |
| 157 | + | |
167 | 158 | | |
168 | 159 | | |
169 | 160 | | |
| |||
182 | 173 | | |
183 | 174 | | |
184 | 175 | | |
185 | | - | |
186 | | - | |
187 | | - | |
| 176 | + | |
188 | 177 | | |
189 | | - | |
190 | | - | |
| 178 | + | |
191 | 179 | | |
192 | 180 | | |
193 | 181 | | |
| |||
200 | 188 | | |
201 | 189 | | |
202 | 190 | | |
203 | | - | |
| 191 | + | |
204 | 192 | | |
205 | 193 | | |
206 | 194 | | |
| |||
223 | 211 | | |
224 | 212 | | |
225 | 213 | | |
226 | | - | |
227 | | - | |
228 | | - | |
| 214 | + | |
229 | 215 | | |
230 | 216 | | |
231 | 217 | | |
232 | 218 | | |
233 | | - | |
234 | | - | |
| 219 | + | |
235 | 220 | | |
236 | 221 | | |
237 | 222 | | |
| |||
242 | 227 | | |
243 | 228 | | |
244 | 229 | | |
245 | | - | |
| 230 | + | |
246 | 231 | | |
247 | 232 | | |
248 | 233 | | |
| |||
252 | 237 | | |
253 | 238 | | |
254 | 239 | | |
255 | | - | |
| 240 | + | |
256 | 241 | | |
257 | 242 | | |
258 | 243 | | |
| |||
274 | 259 | | |
275 | 260 | | |
276 | 261 | | |
277 | | - | |
| 262 | + | |
278 | 263 | | |
279 | 264 | | |
280 | 265 | | |
| |||
286 | 271 | | |
287 | 272 | | |
288 | 273 | | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
289 | 320 | | |
290 | | - | |
291 | | - | |
292 | | - | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
293 | 333 | | |
| 334 | + | |
294 | 335 | | |
295 | 336 | | |
296 | 337 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
0 commit comments