3 ms·
How are you going to garbage collect inside your array? Sounds like you are just evading the problem and reinventing the heap.
by amelius 2y ago
How are you going to garbage collect inside your array? Sounds like you are just evading the problem and reinventing the heap.
- burntsushi 2y agoNot easily. But not all use cases require it. The regex crate makes heavy use of this pattern for finite machine states, for example. But this fits nicely with an arena allocation pattern, so everything can just be dropped at once. Despite this, it's one of the fastest regex engines around: https://github.com/BurntSushi/rebar#summary-of-search-time-benchmarks https://github.com/BurntSushi/rebar#summary-of-search-time-b... Here's a related but more isolated analysis: https://github.com/burntsushi/rsc-regexp https://github.com/burntsushi/rsc-regexp
- amelius 2y agoYou could probably make an even faster regex by JIT-compiling the resulting automaton.
- burntsushi 2y agoThe benchmarks I linked include multiple regex engines with JITs.
- oconnor663 2y agoI'm not sure whether this is exactly what you mean, but when you need to support deletions you can switch to a "generational" collection like Slab or SlotMap. Your indexes are still integers, but under the covers some of the bits get repurposed to disambiguate new elements that reuse old slots.