Commit 6d89652
committed
perf(config): replace chain := []string{} with var; add workspace test
Third code-review pass found three issues:
1. validate.go and kind_extends.go: `chain := []string{}` allocates an
empty backing array on every call. `var chain []string` (nil slice)
defers the first allocation to the initial append, saving one heap
allocation on every call where the loop never appends (kinds without
an extends: chain in validateKindExtends, or when the extends chain
has no schemas in extendsChainSchemas).
2. provenance.go: `allRuleNames` was the last `map[string]bool` presence
set in the file not converted by the previous commit. Changed to
`map[string]struct{}` for consistency with the surrounding code.
3. workspace_test.go: Add TestMemFSDirEntriesIgnoresEmptySegment to
document and pin the empty-name-segment guard in memFS.dirEntries.
A key with a double-slash segment (e.g. "a//b.md") produces an empty
first component after stripping the directory prefix; the nested-if
guard introduced in 9b0fa79 must check `name != ""` before the
seen-map probe. The test constructs memFS directly (bypassing
NewMemWorkspace path.Clean) to exercise this path.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QjbjBieiWMBKURdKVNnPvy1 parent ae1338f commit 6d89652
4 files changed
Lines changed: 32 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
357 | | - | |
| 357 | + | |
358 | 358 | | |
359 | 359 | | |
360 | | - | |
| 360 | + | |
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
293 | 321 | | |
294 | 322 | | |
295 | 323 | | |
| |||
0 commit comments