Dynamic array comparison optimization: check for equal pointers?
Stefan Koch
uplink.coder at googlemail.com
Tue Jun 2 20:23:51 UTC 2020
On Tuesday, 2 June 2020 at 19:38:04 UTC, Johan wrote:
> Hi all,
> I thought that we optimized dynamic array comparison with a
> check to see if the pointers are equal, but I don't see it in
> our array comparison implementation in druntime. Quick checking
> of glibc memcmp also showed that there is no short circuit for
> when the pointers of the slices are equal.
>
> I was expecting something like:
> ```
> if ( sizes are not equal )
> return false;
> if ( pointers are equal )
> return true;
> return memcmp;
> ```
>
> I am surprised that memcmp itself does not implement the
> pointers are equal check. Is there a big impact of adding the
> shortcircuit check to prevent scanning memory?
>
> cheers,
> Johan
I would have expected this optimization to be present as well ...
It seems like a no-brainer.
More information about the Digitalmars-d
mailing list