Commit 24c91c0
committed
perf(output): order jsonDiagnostic/jsonRelatedLocation pointer fields before scalars
internal/output.jsonDiagnostic interleaved Line/Column/
SourceStartLine/Deprecated (scalars) among its string/slice/pointer
fields; jsonRelatedLocation interleaved Line/Column before Message.
Same defect and same fix as internal/lint.Diagnostic and
pkg/mdsmith.Diagnostic: Go's GC ptrdata for a struct spans from
offset 0 through the last pointer-containing field, so a scalar
declared before that point sits inside the scanned span for nothing.
One of these is built per diagnostic on every `--format json` run
(CI pipelines, `mdsmith check --format json`).
Per docs/development/high-performance-go.md "Struct layout": order
fields large-to-small, group pointer fields first and scalars last.
Adds structlayout_test.go with the project's existing
structlayout.AssertPointerFieldsFirst pattern. Reordering the Go
struct fields changes encoding/json's emitted key order (Go encodes
struct fields in declaration order), so TestJSONFormatter_ExactOutput
is updated to match; JSON key order carries no semantic meaning and
no reference doc commits to a specific order, and the CLI's own e2e
JSON tests parse into a map rather than asserting exact text.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SNiF3CVZG2NCizbsTgur4V1 parent efb2d17 commit 24c91c0
3 files changed
Lines changed: 44 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
13 | 19 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
36 | 43 | | |
37 | 44 | | |
| 45 | + | |
| 46 | + | |
38 | 47 | | |
39 | 48 | | |
| 49 | + | |
40 | 50 | | |
41 | 51 | | |
42 | | - | |
43 | 52 | | |
44 | 53 | | |
45 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
174 | | - | |
175 | 173 | | |
176 | 174 | | |
177 | 175 | | |
178 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
0 commit comments