changeset 58640:496bbf554c5c JEP-349-branch

Don't expand LongMap lazily
author egahlin
date Wed, 16 Oct 2019 01:16:12 +0200
parents 7b89c53db169
children 38176d1c5ec2
files src/jdk.jfr/share/classes/jdk/jfr/internal/LongMap.java
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/LongMap.java	Sun Oct 13 16:46:15 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/LongMap.java	Wed Oct 16 01:16:12 2019 +0200
@@ -157,9 +157,6 @@
             // Lazy initialization
             initialize(DEFAULT_SIZE);
         }
-        if (count > 3 * keys.length / 4) {
-            expand(2 * keys.length);
-        }
         if (object == null) {
             object = (T) NULL_OBJECT;
         }
@@ -171,6 +168,12 @@
                 keys[index] = id;
                 objects[index] = object;
                 count++;
+                // Don't expand lazy since it
+                // can cause resize when replacing
+                // an object.
+                if (count > 3 * keys.length / 4) {
+                    expand(2 * keys.length);
+                }
                 return;
             }
             // if it already exists, replace