From 5c7a90a1a5b3b21493021193f9b07b903aec7dd9 Mon Sep 17 00:00:00 2001 From: hannesw Date: Tue, 11 Jun 2013 17:50:10 +0200 Subject: [PATCH] 8015379: PropertyMap.addProperty() is slow Reviewed-by: attila, jlaskey --- nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java b/nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java index 077218d3f4..b724816669 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java @@ -95,7 +95,6 @@ public final class PropertyMap implements Iterable, PropertyListener { */ 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 @@ public final class PropertyMap implements Iterable, PropertyListener { this.spillLength = propertyMap.spillLength; this.fieldCount = propertyMap.fieldCount; this.fieldMaximum = propertyMap.fieldMaximum; - this.hashCode = computeHashCode(); if (Context.DEBUG) { count++; @@ -610,6 +608,9 @@ public final class PropertyMap implements Iterable, PropertyListener { @Override public int hashCode() { + if (hashCode == 0 && !properties.isEmpty()) { + hashCode = computeHashCode(); + } return hashCode; } -- GitLab