Remix.run Logo
shin_lao 2 days ago

What is the core use case for this structure? Because it seems like a very heavy price to pay just to keep value stable, as opposed to make a copy of that value when you need it.

wavemode 2 days ago | parent | next [-]

A stable vector generally improves append performance (because you never have to move the data), allows storing data that can't be moved, and allows for appending while iterating. The downside is slightly worse performance for random lookups (since the data is fragmented across multiple segments) and higher memory usage (depending on implementation).

This "semistable" vector appears to only do the "allow appending while iterating" part, but still maintains a contiguous buffer by periodically moving its contents.

eps 2 days ago | parent | prev [-]

It's basically a form of reference-counted data access as I understand it.

If the code here operates with a bit of data from some container, the container will ensure that this bit will persist until all references to it are gone even if the bit is removed from the container.

Depending on the datamodel this may be handy or even required. Consider some sort of hot-swappable code when both retired and new code versions running in parallel at some point. That sort of thing.