Dynamic array comparison optimization: check for equal pointers?
Johan
j at j.nl
Tue Jun 2 19:38:04 UTC 2020
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
More information about the Digitalmars-d
mailing list