Repository navigation
refactor(comp): shed 90 tokens with no output change - #2027
Conversation
… change Inlines single-use locals of pure or memoized calls, joins lines that fit in 80 columns, reuses rest_use, ty_all and seg_text where they apply, and drops val_brw, the JS early return in emit_chain (its regex never matches JS) and the copy emit_native made of its destination. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Clanker made too much code golfing... |
nicolas-abril
left a comment
There was a problem hiding this comment.
I traced all the inlined locals and found no change to the emitted output. Nice. A few of the inlines move work that used to run once into a per-element loop, though, and several of those are on the JS emit path, which the PR's timing (C emit only) didn't cover. Comments inline. Restoring the hoisted locals (and the FL.js guard) costs a few of the saved tokens and keeps the output identical.
Restores the locals that the previous commit inlined into per-element callbacks (ws in emit_ctr, fs in js_expr, the ctr_flds and let_live of anf, k in emit_tab, add in term_uses, wide in fun_of, done in brw_of, local in facts_ctr, ks in ty_holds, doms in emit_unfold, edges in compile_book, u in let_live), and the FL.js guard of emit_chain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, all nine are right: each of those inlines moved work into a per-element loop or callback (or dropped the
|
anf reads its hoisted spine again (m was left unused), emit_intr keeps its lays local, main_pure's field walk goes back to Bend.tele_open, whose null ends it, and emit_spin, emit_clo and js_lib call emit_native, seg_name, host and c_ids in main's order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Trims
bend2/comp.tsfrom 65,995 to 65,905 ttok (cap 66,000) without changing what the compiler emits.What
term_use(term_uses(x), p)becomesrest_use([x], p)where it doesn't run per element.val_brwis inlined (2 uses), and the twoWL_CONT/WL_IDXpushes inemit_forkare onefile_push.Following #1922's review, type declarations, object literals, if/else statements, for loops, explicit checks and comments are kept as they are. Following review here, no local that a loop or callback reads is inlined,
emit_chainkeeps itsFL.jsguard, calls with side effects (emit_native,seg_name,host,c_ids) run in main's order, andmain_purekeeps the nullableBend.tele_open.Verified (on main e2a7f60; comp.ts is unchanged on main since)
-o x.c) and JS (-o x.js) for every.bendundertests/,demos/andbench/runtime/: 1,911 files, 922 C and 974 JS outputs, with stdout, stderr and exit codes byte-identical to main.comp.tstype-checks with--noUnusedLocals(no errors in comp.ts).🤖 Generated with Claude Code