www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20892] New: [REG2.086] ElfFile comparison suboptimal

https://issues.dlang.org/show_bug.cgi?id=20892

          Issue ID: 20892
           Summary: [REG2.086] ElfFile comparison suboptimal
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: johanengelen weka.io

The alias_this-->opEquals change (
https://dlang.org/changelog/2.086.0.html#alias_this_opEquals) silently resulted
in ElfFile comparison potentially comparing a lot of memory, instead of pointer
comparison as before.

It concerns core.internal.elf.io.ElfIO.ElfFile, member MMapRegion!Elf_Ehdr
ehdr.

Snippet:
```
struct MMapRegion(T)
    alias data this;

    private ubyte[] mappedRegion;
    const(T)* data;
```

Before 2.086, only MMapRegion.data would be compared (pointer comparison), but
since 2.086 now the whole mappedRegion is compared (potentially). Quick
checking of druntime's dynamic array comparison and glibc memcmp showed that
there is no short circuit for when the pointers of the slices are equal.

--
Jun 01 2020