Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-5723

COSName caches already cached hashCode

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.30, 3.0.1 PDFBox, 4.0.0
    • 2.0.31, 3.0.2 PDFBox, 4.0.0
    • None
    • None

    Description

      COSName stores a name (String) and a hash code (int), both are final. The constructor calculates the hashCode as `hashCode = name.hashCode()`. Since the String class itself also caches the hashCode (it is calculated at first access), this is unnecessary and on most JVM implementations wastes 8 bytes of memory per COSName instance (4 for the integer and another 4 for padding). 

      Attachments

        Activity

          People

            lehmi Andreas Lehmkühler
            axh Axel Howind
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: