3 ms·
Looking at that benchmark, marking a function as "static" was enough to make the bounds checks be optimised away. One difference between C++ and Rust (yes, I k
by CJefferson 4y ago
Looking at that benchmark, marking a function as "static" was enough to make the bounds checks be optimised away.
One difference between C++ and Rust (yes, I know they seem to get compared a lot) I like is that the "default function" is the safe one. In Rust you disable bounds checking for a particular, but [] does bounds checking. In C++ you can do "bounds checked access", but [] does unsafe.
In my opinion, it's best if the "default option" users reach for is the safe, but possibly slower option. Then, in a situation where a user is sure about what they are doing, and the boost is worth it, they can reach for the less safe option. In a program I'm currently working on we have disabled bounds checking in exactly two functions, as benchmarking showed it was worth it, and we carefully checked it would be safe to do.
- jcelerier 4y ago> Looking at that benchmark, marking a function as "static" was enough to make the bounds checks be optimised away. and that's nice when you can do this (or apply LTO which would likely give the same result) - you definitely can't always do this. Think proprietary vendor selling a DLL containing some very specific DSP routines.