From 09c062e7aa16534e7efaae4522c2cb03b2662220 Mon Sep 17 00:00:00 2001 From: Bruno Lellis Date: Thu, 2 Dec 2021 22:32:16 -0300 Subject: [PATCH] optimization: change String.replaceAll in favor of Pattern.compile --- .../main/java/com/newrelic/agent/config/AgentConfigImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/config/AgentConfigImpl.java b/newrelic-agent/src/main/java/com/newrelic/agent/config/AgentConfigImpl.java index eb3c69e600..4fd14b95f4 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/config/AgentConfigImpl.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/config/AgentConfigImpl.java @@ -183,6 +183,7 @@ public class AgentConfigImpl extends BaseConfig implements AgentConfig { // per protocol 15+, region aware license keys must match this regex before constructing collector host public static final Pattern REGION_AWARE = Pattern.compile("^.+?x"); + private static final Pattern DOT_HYPHEN_PATTERN = Pattern.compile("[.-]"); // root configs (alphabetized) private final long apdexTInMillis; @@ -585,7 +586,7 @@ public T getValue(String path) { @Override @SuppressWarnings("unchecked") public T getValue(String path, T defaultValue) { - Object value = flattenedProperties.get(path.replaceAll("[.-]", "_")); + Object value = flattenedProperties.get(DOT_HYPHEN_PATTERN.matcher(path).replaceAll("_")); if (value == null) { value = flattenedProperties.get(path); }