kripken/emscripten — pull request #2406 by juj (2014-06-05 03:24:18+00:00)
Title: Typedarray memfs

Putting this up for looks.

This aims to fix the issue https://github.com/kripken/emscripten/issues/2391 .

- Removes the content mode flags, which are unnecessary as the same info can be deduced without tracking such mode fields.
- Now is more aggressive with storing all content initially in typed arrays. This is ideal for all read-only files.
- If data is appended to an existing file that would require resizing the typed array, switches to backing that file with a regular JS array instead.
- Adds a new linker option -s MEMFS_APPEND_TO_TYPED_ARRAYS=1, which if enabled, forces typed arrays to be used in backing even when appending to files is performed. A geometric std::vector -like capacity+used allocation mechanism is implemented to ensure linear time complexity.

I have not yet made any benchmarks with this, just ran the test suites to confirm that everything works. CC @jmuizelaar and @kripken