Commit ef818c0
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 9b0fa79 commit ef818c0
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 | |
|---|---|---|---|
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
269 | 297 | | |
270 | 298 | | |
271 | 299 | | |
| |||
0 commit comments