Commit 5bec363
committed
pgio: optimize append/set functions with direct byte shifts
Replace zero-fill + overwrite pattern with direct byte appends.
Use array pointer cast in SetInt32 to eliminate bounds checks.
Benchmarks show 12-19% improvement in message building:
BindMessage5Params: 164 ns → 132 ns (19% faster)
BindMessage20Params: 922 ns → 780 ns (15% faster)
Simulate10kQueries: 1.37ms → 1.21ms (12% faster)
Assembly comparison for SetInt32:
Before: 134 bytes, 4 bounds checks, 4 panicIndex calls
After: 63 bytes, 1 bounds check, 1 panicSliceConvert call
No functional changes. All existing tests pass.1 parent 9e3a3ad commit 5bec363
1 file changed
Lines changed: 7 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | 3 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
| 4 | + | |
10 | 5 | | |
11 | 6 | | |
12 | 7 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 8 | + | |
17 | 9 | | |
18 | 10 | | |
19 | 11 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
24 | 16 | | |
25 | 17 | | |
26 | 18 | | |
| |||
36 | 28 | | |
37 | 29 | | |
38 | 30 | | |
39 | | - | |
| 31 | + | |
40 | 32 | | |
0 commit comments