Commit e987101
committed
Fix multi-struct rewrite loss by deferring DST rendering to run()
Store dirty *dst.File pointers instead of pre-rendered []byte buffers so
that all struct rewrites within the same file accumulate on the shared DST
before final rendering. The previous approach called decorator.Fprint inside
betteralign() and stored the result in fixOps[fn], silently overwriting any
prior rewrite for the same file; only the last modified struct per file was
preserved.
Also hoist os.Getwd() out of the inspect.Preorder closure so it is called
once per analysis pass instead of once per AST node, and propagate its error
properly rather than printing to stderr and continuing silently.
Move the dNode lookup and hasIgnoreComment check to the top of betteralign()
so ignored structs are skipped before any expensive computation.
Pre-compute architecture suffix strings in removeOtherArches to avoid
repeated string construction inside the inner loop.1 parent 0968379 commit e987101
2 files changed
+37
-30
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
184 | | - | |
| 184 | + | |
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
189 | 198 | | |
190 | 199 | | |
191 | 200 | | |
| |||
198 | 207 | | |
199 | 208 | | |
200 | 209 | | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | 210 | | |
207 | 211 | | |
208 | 212 | | |
| |||
288 | 292 | | |
289 | 293 | | |
290 | 294 | | |
291 | | - | |
| 295 | + | |
292 | 296 | | |
293 | 297 | | |
294 | 298 | | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
302 | 309 | | |
303 | 310 | | |
304 | 311 | | |
| |||
308 | 315 | | |
309 | 316 | | |
310 | 317 | | |
311 | | - | |
| 318 | + | |
312 | 319 | | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
313 | 327 | | |
314 | 328 | | |
315 | 329 | | |
| |||
327 | 341 | | |
328 | 342 | | |
329 | 343 | | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | 344 | | |
338 | 345 | | |
339 | 346 | | |
| |||
362 | 369 | | |
363 | 370 | | |
364 | 371 | | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | 372 | | |
371 | 373 | | |
372 | 374 | | |
373 | 375 | | |
374 | 376 | | |
375 | 377 | | |
376 | 378 | | |
377 | | - | |
| 379 | + | |
378 | 380 | | |
379 | 381 | | |
380 | 382 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
32 | 37 | | |
33 | 38 | | |
34 | 39 | | |
35 | 40 | | |
36 | | - | |
37 | | - | |
| 41 | + | |
| 42 | + | |
38 | 43 | | |
39 | 44 | | |
40 | 45 | | |
| |||
0 commit comments