3 ms·
Popping from the source is likely a big source of allocator / copy overhead. It’s probably better to just iterate over an input array. The algorithm in the ar
by hedora 6y ago
Popping from the source is likely a big source of allocator / copy overhead. It’s probably better to just iterate over an input array.
The algorithm in the article would be quadratic in perl 5; not sure about rust or js, but the point still stands: It’s likely to see asymptotic performance differences in different languages.
(Edit: it’s not quadratic in perl. If it used shift to pull from the front of the array it would be.)
- Measter 6y agoPopping doesn't touch the allocator, as it doesn't resize the backing storage. The only thing being copied is the String struct (24 bytes), which while unnecessarily large here, wouldn't be the bottleneck.