From 355ceab073246b68f6c7cb0de531d0592548e38e Mon Sep 17 00:00:00 2001 From: brharrington Date: Fri, 26 Jul 2024 15:24:57 -0500 Subject: [PATCH] atlas: simplify compare method for name (#1145) Before the check for name against k1 could happen multiple times. --- .../java/com/netflix/spectator/atlas/impl/QueryIndex.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/spectator-reg-atlas/src/main/java/com/netflix/spectator/atlas/impl/QueryIndex.java b/spectator-reg-atlas/src/main/java/com/netflix/spectator/atlas/impl/QueryIndex.java index 6b9e84acf..7ac15e396 100644 --- a/spectator-reg-atlas/src/main/java/com/netflix/spectator/atlas/impl/QueryIndex.java +++ b/spectator-reg-atlas/src/main/java/com/netflix/spectator/atlas/impl/QueryIndex.java @@ -94,10 +94,8 @@ private static QueryIndex empty(CacheSupplier cacheSupplier) { * This allows the {@link Id} to be traversed in order while performing the lookup. */ private static int compare(String k1, String k2) { - if ("name".equals(k1) && "name".equals(k2)) { - return 0; - } else if ("name".equals(k1)) { - return -1; + if ("name".equals(k1)) { + return "name".equals(k2) ? 0 : -1; } else if ("name".equals(k2)) { return 1; } else {