Skip to content

[MEMFS] Assume FS.write is takes a TypedArray.#26413

Open
sbc100 wants to merge 1 commit intoemscripten-core:mainfrom
sbc100:assume_typed_array
Open

[MEMFS] Assume FS.write is takes a TypedArray.#26413
sbc100 wants to merge 1 commit intoemscripten-core:mainfrom
sbc100:assume_typed_array

Conversation

@sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Mar 8, 2026

We have higher level wrappers createDataFile and writeFile which also accept Array and string, but it simpler if the lower level APIs can just assume TypedArray.

This simplifies the code and reduces code size. We have assertions to check this in debug builds.

Followup to #26398 and #26411

@sbc100 sbc100 force-pushed the assume_typed_array branch 3 times, most recently from b78a8cd to 8ac558e Compare March 8, 2026 17:57
@sbc100 sbc100 requested review from RReverser and brendandahl March 8, 2026 17:57
@sbc100 sbc100 force-pushed the assume_typed_array branch from 8ac558e to 618cc68 Compare March 8, 2026 17:58
@sbc100 sbc100 requested a review from tlively March 8, 2026 19:10
@sbc100 sbc100 enabled auto-merge (squash) March 8, 2026 19:10
Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this affect compatibility with WasmFS? I mean, does the parallel WasmFS API behave the same?

@sbc100
Copy link
Collaborator Author

sbc100 commented Mar 9, 2026

Does this affect compatibility with WasmFS? I mean, does the parallel WasmFS API behave the same?

Hmm, good call. I updated wasmfs too and created a shared utility for converting incoming file data.

@sbc100 sbc100 force-pushed the assume_typed_array branch from 618cc68 to cd0438f Compare March 9, 2026 20:58
Copy link
Collaborator Author

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you like I can split out the new FS_fileDataToTypedArray function as separate NFC?

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to split stuff out here, imo

We have higher level wrappers such as `createDataFile` which also
accept `Array` and `string`, but it simpler if the lower level APIs
just assume `TypedArray`.

This simplifies the code and reduces code size.  We have assertions to
check this in debug builds.

Followup to emscripten-core#26398 and emscripten-core#26411
@sbc100 sbc100 force-pushed the assume_typed_array branch from cd0438f to ab3c82d Compare March 9, 2026 22:01
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