Skip to content

refactor(io): share file read and write implementations - #950

Closed
tachytelicdetonation wants to merge 1 commit into
bendlang:mainfrom
tachytelicdetonation:contrib/share-file-io
Closed

tachytelicdetonation wants to merge 1 commit into
bendlang:mainfrom
tachytelicdetonation:contrib/share-file-io

Conversation

@tachytelicdetonation

Copy link
Copy Markdown
Contributor

The three file readers repeat buffer setup and byte-list packing; the two writers repeat their write loop and completion handling. Keep those operations together in file_read.{c,js} and file_write.{c,js}, and remove the six redundant source files.

The C entry points remain guarded by their own CIDs so importing one operation does not require the others. Text decoding, positional reads, byte validation, error results, and handle ownership keep their existing behavior. Update Base's import paths and the source inventory accordingly.

Net: 48 fewer lines and 645 fewer ttok across the changed files. No changes to the compiler or language kernel.

Verification:

  • Nine existing IO tests pass through the default runner, emitted JS, and native C on both macOS arm64 and Linux arm64: file_binary, file_roundtrip, read_bytes, write_nul_bytes, fail_keeps_handle, read_leading_bom, path_utf8, codec_seal_shared, and tcp_send_slow_peer (54 checks). The seven direct file tests also passed before the refactor.
  • Built and ran all 31 nonempty combinations of the five operations in C and JS on both platforms (124 checks), covering individual-effect imports and shared-source deduplication.
  • All 16 runtime benchmarks generate byte-identical C and JS versus 99f9c6cd. Repository file/token gate: 46/46; git diff --check passes.

The private mini-cluster test and performance gates were not available; no cluster timing results are claimed.

VictorTaelin pushed a commit that referenced this pull request Sep 21, 2026
file_read.{c,js} carries the positional and byte readers and file_write.{c,js} the byte writer, each entry guarded by its own CID, so importing one operation still pulls only that one. Six effect files are gone. (PR #950)
@VictorTaelin

Copy link
Copy Markdown
Contributor

Merged into 2.0.25 under your authorship, thank you: −641 ttok in the effects, every file test identical on the three lanes, and each entry still guarded by its own CID.

Note: this reply was written by an AI after it reported the issue to me and I made the decision. If anything here is wrong, reply and I will review it myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants