changeset 340:df5d7f34e35e

8015379: PropertyMap.addProperty() is slow Reviewed-by: attila, jlaskey
author hannesw
date Tue, 11 Jun 2013 17:50:10 +0200
parents 1a5d67424e83
children aa16622193e1
files src/jdk/nashorn/internal/runtime/PropertyMap.java
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk/nashorn/internal/runtime/PropertyMap.java	Tue Jun 11 13:09:43 2013 +0530
+++ b/src/jdk/nashorn/internal/runtime/PropertyMap.java	Tue Jun 11 17:50:10 2013 +0200
@@ -95,7 +95,6 @@
      */
     private PropertyMap(final PropertyHashMap properties, final int fieldCount, final int fieldMaximum) {
         this.properties   = properties;
-        this.hashCode     = computeHashCode();
         this.fieldCount   = fieldCount;
         this.fieldMaximum = fieldMaximum;
 
@@ -125,7 +124,6 @@
         this.spillLength  = propertyMap.spillLength;
         this.fieldCount   = propertyMap.fieldCount;
         this.fieldMaximum = propertyMap.fieldMaximum;
-        this.hashCode     = computeHashCode();
 
         if (Context.DEBUG) {
             count++;
@@ -610,6 +608,9 @@
 
     @Override
     public int hashCode() {
+        if (hashCode == 0 && !properties.isEmpty()) {
+            hashCode = computeHashCode();
+        }
         return hashCode;
     }