Is D slow?
Nicholas Wilson via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jun 10 06:43:48 PDT 2017
On Saturday, 10 June 2017 at 12:44:07 UTC, Honey wrote:
> 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?
My bad I misread the original quote, misread that as performance
increase.
turning bounds checks off should always result in faster code.
More information about the Digitalmars-d-learn
mailing list