D perfomance

IGotD- nise at nise.com
Wed Apr 29 12:37:29 UTC 2020


On Wednesday, 29 April 2020 at 10:46:57 UTC, random wrote:
>
> Ok in this simple case it's obvius.
> For a real world example look at the source for strcmp():
> https://code.woboq.org/userspace/glibc/string/strcmp.c.html
>
> The trick is to load the value in a variable. The compiler 
> can't optimize multiple pointer reads from the same pointer 
> because the content could already be changed by an other 
> pointer. restrict solves that, but if you now what is happening 
> and why you can solve that by hand.

In the strcmp example, shouldn't the compiler be able to do the 
same optimizations as you would use restrict because both 
pointers are declared const and the content do not change?


More information about the Digitalmars-d mailing list