Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8283175

Add equals/hashcode to MemorySegment

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • None
    • repo-panama
    • tools

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              mcimadamore Maurizio Cimadamore
              mcimadamore Maurizio Cimadamore
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: