Skip to content

Commit 9b6c445

Browse files
dougqhclaude
andcommitted
Inline equals in StringIndex probe; drop the eq() guard helper
The `a == b || a.equals(b)` guard is a wash when equals inlines (benchmark: a monomorphic String receiver lets equals's own leading `this == b` provide the identity fast-path). And the eq() helper was an extra call in the hot probe, consuming inline depth/budget; inlining `.equals()` directly flattens indexOf -> equals, making equals more likely to inline -- the regime where the guard is moot anyway. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 62b9e64 commit 9b6c445

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

internal-api/src/main/java/datadog/trace/util/StringIndex.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public static int put(int[] hashes, String[] names, String name, int h) {
223223
names[i] = name;
224224
return i;
225225
}
226-
if (hashes[i] == h && eq(names[i], name)) {
226+
if (hashes[i] == h && names[i].equals(name)) {
227227
return i; // already present
228228
}
229229
}
@@ -239,7 +239,7 @@ public static int indexOf(int[] hashes, String[] names, String name, int h) {
239239
if (sh == 0) {
240240
return -1;
241241
}
242-
if (sh == h && eq(names[i], name)) {
242+
if (sh == h && names[i].equals(name)) {
243243
return i;
244244
}
245245
}
@@ -288,10 +288,5 @@ public static long lookupOrDefault(
288288
int slot = indexOf(hashes, names, key);
289289
return slot >= 0 ? data[slot] : defaultValue;
290290
}
291-
292-
// `a` is a stored name on an occupied slot (never null); `b` is a non-null query.
293-
private static boolean eq(String a, String b) {
294-
return a == b || a.equals(b); // interned literals hit the == fast path
295-
}
296291
}
297292
}

0 commit comments

Comments
 (0)