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?
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?