From 44436f87d627b2ee7e5383ef84ffed3a6c0e37e9 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Tue, 24 Dec 2024 14:42:45 +0100 Subject: [PATCH] Cache hashCode of PropertyName Given we are adding quite a lot of elements, there are a lot of chances the maps will have to be resized several times. --- .../src/main/java/io/smallrye/config/PropertyName.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/implementation/src/main/java/io/smallrye/config/PropertyName.java b/implementation/src/main/java/io/smallrye/config/PropertyName.java index c501a2f39..7a11a7598 100644 --- a/implementation/src/main/java/io/smallrye/config/PropertyName.java +++ b/implementation/src/main/java/io/smallrye/config/PropertyName.java @@ -4,9 +4,11 @@ public class PropertyName { private final String name; + private final int hashCode; public PropertyName(final String name) { this.name = name; + this.hashCode = buildHashCode(); } public String getName() { @@ -97,6 +99,10 @@ private static boolean equalsInternal(final String name, final String other) { @Override public int hashCode() { + return hashCode; + } + + private int buildHashCode() { int h = 0; int length = name.length(); boolean quotesOpen = false;