Commit 9b26d44
committed
perf(decode): pool rec buffer in unmarshalValue
Replaces per-call make([]byte, 0, 64) with a sync.Pool of reusable
recording buffers in unmarshalValue. Eliminates 1 alloc per
Unmarshaler.UnmarshalMsgpack call. Oversized buffers (>4KB) are
dropped to prevent unbounded pool growth.
DecodeRaw is not pooled because the caller owns the returned slice.1 parent 82f46cf commit 9b26d44
1 file changed
Lines changed: 24 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
12 | 20 | | |
13 | 21 | | |
14 | 22 | | |
| |||
233 | 241 | | |
234 | 242 | | |
235 | 243 | | |
236 | | - | |
| 244 | + | |
| 245 | + | |
237 | 246 | | |
238 | | - | |
| 247 | + | |
239 | 248 | | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
240 | 252 | | |
241 | 253 | | |
242 | | - | |
| 254 | + | |
243 | 255 | | |
244 | 256 | | |
245 | 257 | | |
246 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
247 | 267 | | |
248 | 268 | | |
249 | 269 | | |
| |||
0 commit comments