Commit 264c06a
triedb/pathdb: use binary.append to eliminate the tmp scratch slice (#32250)
`binary.AppendUvarint` offers better performance than using append
directly, because it avoids unnecessary memory allocation and copying.
In our case, it can increase the performance by +35.8% for the
`blockWriter.append` function:
```
benchmark old ns/op new ns/op delta
BenchmarkBlockWriterAppend-8 5.97 3.83 -35.80%
```
---------
Signed-off-by: jsvisa <delweng@gmail.com>
Co-authored-by: Gary Rong <garyrong0905@gmail.com>1 parent 83aa643 commit 264c06a
File tree
2 files changed
+27
-21
lines changed- triedb/pathdb
2 files changed
+27
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
225 | 224 | | |
226 | 225 | | |
227 | 226 | | |
228 | 227 | | |
229 | | - | |
230 | 228 | | |
231 | 229 | | |
232 | | - | |
233 | | - | |
234 | | - | |
| 230 | + | |
| 231 | + | |
235 | 232 | | |
236 | 233 | | |
237 | 234 | | |
| |||
241 | 238 | | |
242 | 239 | | |
243 | 240 | | |
244 | | - | |
245 | 241 | | |
246 | 242 | | |
247 | 243 | | |
| |||
268 | 264 | | |
269 | 265 | | |
270 | 266 | | |
271 | | - | |
272 | | - | |
| 267 | + | |
273 | 268 | | |
274 | | - | |
275 | 269 | | |
276 | 270 | | |
277 | 271 | | |
278 | | - | |
279 | | - | |
| 272 | + | |
280 | 273 | | |
281 | 274 | | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | 275 | | |
288 | 276 | | |
289 | 277 | | |
| |||
392 | 380 | | |
393 | 381 | | |
394 | 382 | | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
399 | 386 | | |
400 | | - | |
| 387 | + | |
401 | 388 | | |
402 | 389 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
0 commit comments