Skip to content

Commit

Permalink
Effectively revert cl/700073681, pending performance impact analysis
Browse files Browse the repository at this point in the history
RELNOTES=n/a
PiperOrigin-RevId: 700838431
  • Loading branch information
nick-someone authored and Flogger Team committed Nov 28, 2024
1 parent 7f14d9d commit 56a1eb3
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions api/src/main/java/com/google/common/flogger/LogSite.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,38 +204,11 @@ public boolean equals(@Nullable Object obj) {
return methodName.equals(other.methodName)
&& encodedLineNumber == other.encodedLineNumber
// Check classname last because it isn't cached
&& internalNamesCompatible(internalClassName, other.internalClassName);
&& getClassName().equals(other.getClassName());
}
return false;
}

// The compile-time injection mechanism uses a slash-separated class name, but
// unfortunately some users have been using dot-separated class names. We need to be able to
// make these equivalent, but want to avoid allocating/copying strings.
@SuppressWarnings("ReferenceEquality")
private static boolean internalNamesCompatible(String s1, String s2) {
if (s1 == s2) { // We expect most internal class names to be interned.
return true;
}

if (s1.length() != s2.length()) {
return false;
}

for (int i = 0; i < s1.length(); i++) {
char c1 = s1.charAt(i);
char c2 = s2.charAt(i);
if (c1 != c2) {
// If the characters are not equal, but the slash/dot difference is accounted for, then
// consider them equivalent.
if (!(c1 == '/' && c2 == '.') && !(c1 == '.' && c2 == '/')) {
return false;
}
}
}
return true;
}

@Override
public int hashCode() {
if (hashcode == 0) {
Expand Down

0 comments on commit 56a1eb3

Please sign in to comment.