On Saturday, 10 June 2017 at 12:23:05 UTC, Nicholas Wilson wrote:
On Saturday, 10 June 2017 at 12:16:34 UTC, Honey wrote:
Is it expected that turning off bounds checking can lead to a
performance decrease?
Yes, with it on you are doing an "is the index <= the length"
for every array access. Now some of them can be elided by the
complier when it can prove that the index is always in bounds
but it is generally dangerous to do so as it opens up the
possibility of buffer overflow.
Are you saying that introducing additional checks enables the
optimizer to eliminate more or more costly checks than it could
without introducing those additional checks in the first place?
Can you give an example?