# HG changeset patch # User hannesw # Date 1370965810 -7200 # Node ID 35288b76c9ffc74b2abb580236e655ed4d020d7a # Parent 7d5c1fa9c82c635ccdeba87550b2738763e3535b 8015379: PropertyMap.addProperty() is slow Reviewed-by: attila, jlaskey diff -r 7d5c1fa9c82c -r 35288b76c9ff nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java --- a/nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java Tue Jun 11 13:09:43 2013 +0530 +++ b/nashorn/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; }