IdIndexEntry: fix always true != on different objects, avoid allocation if possible

GitOrigin-RevId: 29ca05230623c996c0b909fba285c279fea8571e
This commit is contained in:
Peter Gromov
2020-06-16 20:45:25 +03:00
committed by intellij-monorepo-bot
parent 2f4d50c774
commit b7f2777d52
2 changed files with 5 additions and 4 deletions
@@ -21,9 +21,10 @@ public class IdDataConsumer {
if (end == start) return;
final IdIndexEntry entry = new IdIndexEntry(charSequence, start, end, true);
addOccurrence(entry, occurrenceMask);
final IdIndexEntry entryNoCase = new IdIndexEntry(charSequence, start, end, false);
if (entryNoCase != entry) {
addOccurrence(entryNoCase, occurrenceMask);
int hashNoCase = IdIndexEntry.getWordHash(charSequence, start, end, false);
if (hashNoCase != entry.getWordHashCode()) {
addOccurrence(new IdIndexEntry(hashNoCase), occurrenceMask);
}
}
@@ -62,7 +62,7 @@ public final class IdIndexEntry {
return "IdIndexEntry[hash: " + myWordHashCode +"]";
}
private static int getWordHash(@NotNull CharSequence line, int start, int end, boolean caseSensitive) {
static int getWordHash(@NotNull CharSequence line, int start, int end, boolean caseSensitive) {
if (start == end) return 0;
char firstChar = line.charAt(start);
char lastChar = line.charAt(end - 1);