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

Shortcut String equality checks by checking equality of the value array

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      JEP 192, "String Deduplication in G1", added a deduplication system for Strings on the heap to the G1 Garbage Collector. However, those don't change the String object, but the value array. Given that in the cases where the same String object is passed the value array is still the same, the equals check could shortcut to checking equality of the value array and skip looping through every character in many cases, when the G1 GC is being used, which is quite likely to be the case given it's the default GC.

      Risks:
      When not using the G1 Garbage Collector, it may introduce a bit of overhead in the reference equality check of the value array field that would just be checking reference equality of the String object otherwise, though I'm not sure how much that is in a real world scenario.


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: