6 ms·
Yes. You have to write `unsafe { ... }` around it, so there's an ergonomic penalty plus a more nebulous "sense that you're doing something dangerous that might
by oconnor663 1y ago
Yes. You have to write `unsafe { ... }` around it, so there's an ergonomic penalty plus a more nebulous "sense that you're doing something dangerous that might get some skeptical looks in code review" penalty, but the resulting assembly will be the same as indexing in C.
- hypeatei 1y agoI figured, but I guess I don't understand this argument then. SQLite as a project already spends a lot of time on quality so doing some `unsafe` blocks with a `// SAFETY:` comment doesn't seem unreasonable if they want to avoid the compiler inserting a panic branch for bounds checks.
- Ferret7446 1y agoIf you put unsafe around almost all of your code (array indexing) aren't you better off just writing C?
- aw1621107 1y agoPerhaps if the only thing you're doing is array indexing? Though I'm not sure that would apply in this particular case anyways.
- tomjakubowski 1y agoIn many cases LLVM can prove the bounds check is redundant or otherwise is unnecessary and will optimize it away.