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

(coll) LinkedHashMap$Entry.recordAccess() is too expensive for the first entry

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • P4
    • Resolution: Duplicate
    • 6
    • None
    • core-libs

    Description

      A DESCRIPTION OF THE REQUEST :
      LinkedHashMap$Entry.recordAccess() always does a remove()/addBefore() if accessInOrder = true. in some uses it is quite common to access the same element many times. it would be nice if recordAccess() would skip the remove()/addBefore() if the entry is already the first entry.

      all that is needed is:

       if (before != lm.header)
       {
          remove();
          addBefore();
       }

      there are plenty of other optimizations that could be made but this one is so simple and yet can save 6 unnecessary assignments that it seems worthy

      JUSTIFICATION :
      w/o this a performance sensitive client might be inclined to keep a reference to the first entry themselves to circumvent LinkedHashMap's expensive get() overhead.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: