4 ms·
Some minor disadvantages: * Indices are likely to increase register pressure slightly, as unoptimized code must keep around the base as well (and you can't ass
by o11c 1y ago
Some minor disadvantages:
* Indices are likely to increase register pressure slightly, as unoptimized code must keep around the base as well (and you can't assume optimization will happen). In many cases the base is stored in a struct so you'll also have to pay for an extra load stall.
* With indices, you're likely to give up on type safety unless your language supports zero-overhead types and you bother to define and use appropriate wrappers. Note in particular that "difference between two indices" should be a different type than "index", just like for pointers.
- IshKebab 1y agoOn the latter point, I always use this in Rust: https://github.com/zheland/typed-index-collections https://github.com/zheland/typed-index-collections