Commit d45f0e1
committed
Return pointers from Materialize to avoid struct copies
Change Materialize() to return []*ServerTool instead of []ServerTool.
This avoids copying the entire ServerTool struct (which includes the
JSON schema) for each tool in the result.
Benchmark improvement:
- Materialize: 6199ns → 1114ns (5.6x faster)
- Memory: 12584B → 472B (27x less)
- Allocations: 4 → 3
The returned pointers reference the cached tools in the index.
Callers must not modify them.1 parent 2556d72 commit d45f0e1
1 file changed
+5
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
219 | | - | |
| 219 | + | |
| 220 | + | |
220 | 221 | | |
221 | 222 | | |
222 | | - | |
| 223 | + | |
223 | 224 | | |
224 | 225 | | |
225 | 226 | | |
226 | | - | |
| 227 | + | |
227 | 228 | | |
228 | 229 | | |
229 | 230 | | |
| |||
236 | 237 | | |
237 | 238 | | |
238 | 239 | | |
239 | | - | |
| 240 | + | |
240 | 241 | | |
241 | 242 | | |
242 | 243 | | |
| |||
0 commit comments