You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For whatever reason when I use array_ref!() and then look at the generated assembly, I can see the compiler for whatever reason is not able to elude the bounds checking when the array is split inside of the macro. This happens even at -O 3, and it is directly surrounded by an if check on the length of the slice.
I was able to work around it, by moving the slice outside of the macro. Creating a new macro where the caller has to pre-slice things so the sliced passed in is exactly the side of the desired array.
While this is a little more awkward to call, it is a lot easier to explain and because the compiler is able to elude the bounds checks performs better. It may be worth incorporating this method.
The text was updated successfully, but these errors were encountered:
Yes. When I use the array_ref and look at the assembly generated it always seems to have a branch to panic in the event that the length is out of bounds, even when it's enclosed in an if statement explicitly testing the length. I'm not sure why. Something about the way the code gets structured.
For whatever reason when I use
array_ref!()
and then look at the generated assembly, I can see the compiler for whatever reason is not able to elude the bounds checking when the array is split inside of the macro. This happens even at-O 3
, and it is directly surrounded by anif
check on the length of the slice.I was able to work around it, by moving the slice outside of the macro. Creating a new macro where the caller has to pre-slice things so the sliced passed in is exactly the side of the desired array.
While this is a little more awkward to call, it is a lot easier to explain and because the compiler is able to elude the bounds checks performs better. It may be worth incorporating this method.
The text was updated successfully, but these errors were encountered: