Commit 8c2439a
authored
[Witness] Minor optimization to witnessing request (#927)
I noticed a deep lint warning about the string appending, and then
decided to modernize it and benchmark it. While I was there, I did it
properly to pre-allocate a byte array for the b64 encoding. It's 5x
faster and and uses a lot fewer memory allocations now.
```
// New
BenchmarkBuildRequestBody-24 533068 2524 ns/op 2082 B/op 7 allocs/op
// Old
BenchmarkBuildRequestBody-24 95288 12502 ns/op 14301 B/op 65 allocs/op
```1 parent 41ff86c commit 8c2439a
2 files changed
Lines changed: 43 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | 294 | | |
307 | 295 | | |
308 | 296 | | |
309 | 297 | | |
310 | | - | |
| 298 | + | |
311 | 299 | | |
312 | 300 | | |
313 | 301 | | |
| |||
390 | 378 | | |
391 | 379 | | |
392 | 380 | | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 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 | + | |
0 commit comments