3 ms·
I agree with some of this, and the author could've made a better case for from/to_chars: - Afaik stoi and friends depend on the locale, so it's not hard to bel
by OvbiousError 2y ago
I agree with some of this, and the author could've made a better case for from/to_chars:
- Afaik stoi and friends depend on the locale, so it's not hard to believe this introduced additional overhead. The implicit locale dependency is also often very surprising.
- std::stoi only accepts std::string as input, so you're forced to allocate a string to use it. std::from_chars does not.
- from/to_chars don't throw. As far as I know this won't affect performance if it doesn't happen, it does mean you can use these functions in environments where exceptions are disabled.
- eptcyka 2y agoLocale env stuff is inherently thread unsafe, which is the main reason to never rely on it.
- deeringc 2y agoThere's also the new Ryu algorithm that is being used, which is probably the biggest speed up. https://github.com/ulfjack/ryu https://github.com/ulfjack/ryu
- badmintonbaseba 2y agoAFAIK the state of the art now is "dragonbox": https://github.com/jk-jeon/dragonbox https://github.com/jk-jeon/dragonbox