-
Bug
-
Resolution: Fixed
-
P3
-
None
-
repo-panama
MemorySegment should have a way to compare its instances; this could be useful when e.g. using a memory segment as a hashmap key. Of course there are two possible ways to compare a segment:
* shallow comparison: we just compare segment properties such as size and backing region, to make sure they point to the same region.
* structural comparison: we perform a byte-wise comparison of the segment contents.
The latter operation, while useful, is also very expensive (as its complexity depends on the segment size). MemorySegment already provides a way to compare contents (see MemorySegment::mismatch), so what makes most sense here is to compare segments by making sure they point to the same memory region.
* shallow comparison: we just compare segment properties such as size and backing region, to make sure they point to the same region.
* structural comparison: we perform a byte-wise comparison of the segment contents.
The latter operation, while useful, is also very expensive (as its complexity depends on the segment size). MemorySegment already provides a way to compare contents (see MemorySegment::mismatch), so what makes most sense here is to compare segments by making sure they point to the same memory region.