3 ms·
Unless this was updated after your post, I think it was covered in the following line: > It's certainly possible to build things where bounds checking makes a
by epage 3y ago
Unless this was updated after your post, I think it was covered in the following line:
> It's certainly possible to build things where bounds checking makes a difference. This just isn't that.
I will add that idiomatic Rust causes a good number of bounds checks to be optimized away. Its impressive the difference this can make. I maintain a parser combinator library that started as a fork. With some simple changes, I've seen massive performance improvements and my best guess is that those changes allowed bounds checks to be removed.
- norman784 3y agoCan you share what kind of changes, in your case, improved the performance?
- vlovich123 3y agoPossible I missed it when I read it. Would need the author to indicate whether or not it was edited. Yes, idiomatic Rust can cause a number of bounds checks to be elided when using iterators. Typically that's when you have all the data that you need to process up front. When you don't have that ability (e.g. data is being fed in piecemeal and you're copying into a temporary buffer), the bounds checking elision is something you need to do yourself.
- cmrx64 3y agocan you elaborate? rust iterators seem quite capable of streaming in the fashion you suggest.
- vlovich123 3y agoIf I have a buffer in a library and the external API is “append to buffer”, each append will do a bounds check. I’m not aware of an iterator API would work especially considering that the iterator would hold ownership of the buffer which would be incompatible with the call flow returning to the user after the append.