rust-bakery / nom

Rust parser combinator framework
MIT License
9.53k stars 806 forks source link

Parse Arc'ed String without allocation #1372

Open futursolo opened 3 years ago

futursolo commented 3 years ago

Recently, I've been working on a parser that parses CSS.

And parsed stylesheets needs to live 'static (or owned) due to the fact that they are registered in a cache. And I have realised that removing .to_string() would make the parser much faster when parsing complex stylesheets. (The library targets wasm so I cannot use jemalloc.).

Would it be possible to have a (Arc<Cow<'static, str>>, Range<usize>) implementation on substring that dereferences to a &str to avoid allocation like what ArcStr is doing?

Or is this already possible and I am missing something?

Stargateur commented 3 years ago

how arc would speed up anything ?