Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide API for reading source text from disk into a buffer #94

Open
overlookmotel opened this issue Aug 22, 2024 · 0 comments
Open

Provide API for reading source text from disk into a buffer #94

overlookmotel opened this issue Aug 22, 2024 · 0 comments

Comments

@overlookmotel
Copy link

The most common use case for Oxc is reading a file from disk and parsing it.

Currently the parser takes a &str. We could add an API to read a file from disk into a SourceText buffer which is then passed to parser. Possibly SourceText would store the data in the arena.

There's a few advantages to this:

  1. If you reuse the same SourceText buffer over and over when parsing many files, that'd likely be a perf gain, as source text would always be in a block of memory which is warm in the cache.
  2. It'd remove the cost of string copying for Remove bounds checks in Lexer by padding source #20.
  3. It'd be useful for AST transfer for the source text to be in the arena - could make for more efficient code for extracting strings from the serialized buffer.
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

No branches or pull requests

1 participant