Repository navigation
comp.ts sheds 65 tokens with the same output - #1562
Closed
nicolas-abril wants to merge 2 commits into
Closed
nicolas-abril wants to merge 2 commits into
nicolas-abril wants to merge 2 commits into
Conversation
quant_live and ty_clo fold into their callers, F32's intr reads VIEW's f32_bits group, bind_pop and emit_args recount through bind_set, a few if/return pairs in the C runtime become one conditional, and comments that restate their code go. The emitted C and JS for every .bend under tests/, demos/ and bench/runtime/ is byte-identical apart from those rewritten runtime lines. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The cut comments carried what the code does not say (a segment's entry, what crosses to a host, an effect source's single read, show_f32's shortest round trip), and the if/return pairs read better than the conditionals that replaced them. 65 of the 312 tokens stay shed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
nicolas-abril
added a commit
that referenced
this pull request
Oct 14, 2026
…s gone (-602 ttok) - The compiler: bind_set, ty_adt and ck.tld are reused where the code repeated them; quant_live and ty_clo fold into their callers; seg_new takes its parameters' values; emit_match names its tag test once; js_call and js_expr default their usual arguments; F32's intrinsic reuses VIEW; tag lists are one string. - The C runtime: ERR_* is an enum; err_post is a macro on both sides; term_buf folds into term_blk; WL_ARGS takes its count directly and pushes with WL_PUSHN; Metal uses the stdint typedefs; redundant casts, a dead show_val prototype and single-use temporaries go. - The IO layer: one io_parked walk for io_wait's two loops; fcntl.h is included once; IoWork is declared once; strcmp tests read !strcmp. - The JS runtime: f32_show lets its loop reach inf; io_strerror folds into io_fail; io_addr checks a byte with one test; cmp_new is one line. Absorbs #1562. Emitted C and JS stay byte-identical for every test where only the compiler changed; the C and JS test runs match main. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
comp.tsgoes from 63,968 to 63,903 ttok, against its 64k cap. The emitted C is unchanged, and the emitted JS changes only in two line joins.Every cut keeps the output the same:
quant_live(4 callers) andty_clo(1 caller) inline into their callers.OPTIMIZED.F32.F32.intr: reads group 2 ofVIEW(itsf32_bitsarm) instead of repeating that regex.bind_pop,emit_args: recount throughbind_set.nis at least 1 at both sites, sobind_setalways takes its set branch.cmp_newandf32_showgo on one line each, as do two wrapped TS lines (ctr_adt,js_expr).An earlier version also cut comments and turned if/return pairs into conditionals. Those are reverted: the comments carried information the code doesn't, and the if statements read better.
Verification
compile_book,js_bookandjs_libfor all 1,705.bendfiles undertests/,demos/andbench/runtime/with the old and newcomp.ts. Outputs are byte-identical apart from the two JS line joins. This ran on the larger cut, of which this PR is a subset.macOS only; the cluster test gate hasn't been run.
🤖 Generated with Claude Code