Commit 1043d55
committed
review: fix double-scan, allocation regression, and test gaps
Four cleanup fixes from the round-2 code review pass:
- requiredstructure/isPIOpenLine: eliminate redundant double-scan of
the leading-space prefix (CountLeadingSpaces then TrimLeft on same
raw). One TrimLeft now derives both the trimmed slice and the indent
count via len difference.
- orderedlistnumbering/checkListLines,checkItem: revert strconv.Itoa +
string concatenation back to fmt.Sprintf. The concat form makes 3-4
allocations per diagnostic versus Sprintf's ~1 via its pooled pp.
- astutil_test/TestCollectSectionHeadings_Memoized: add require.Len
guard on h2 so a broken memoization path produces a clear assertion
failure instead of a panic on h2[0].
- astutil_test/TestCountLeadingSpaces: add the space-then-tab boundary
case (" \tabc" → 1) to the canonical unit test; the case existed in
listindent/helpers_test.go but not in astutil's own test.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gj8AvSb7r12iqa7r3vYYof1 parent 834b560 commit 1043d55
3 files changed
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
534 | 534 | | |
535 | 535 | | |
536 | 536 | | |
| 537 | + | |
537 | 538 | | |
538 | 539 | | |
539 | 540 | | |
| |||
821 | 822 | | |
822 | 823 | | |
823 | 824 | | |
| 825 | + | |
824 | 826 | | |
825 | 827 | | |
826 | 828 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
139 | | - | |
| 138 | + | |
140 | 139 | | |
141 | 140 | | |
142 | 141 | | |
| |||
163 | 162 | | |
164 | 163 | | |
165 | 164 | | |
166 | | - | |
167 | | - | |
| 165 | + | |
168 | 166 | | |
169 | 167 | | |
170 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1475 | 1475 | | |
1476 | 1476 | | |
1477 | 1477 | | |
1478 | | - | |
| 1478 | + | |
| 1479 | + | |
1479 | 1480 | | |
1480 | 1481 | | |
1481 | | - | |
1482 | 1482 | | |
1483 | 1483 | | |
1484 | 1484 | | |
| |||
0 commit comments