Skip to content

Commit

Permalink
Fix constant pool parser early-exiting instead of checking all strings (
Browse files Browse the repository at this point in the history
#90)

Use a helper variable instead of the label-break pattern, the latter
is ugly and error-prone, in my opinion
  • Loading branch information
embeddedt authored Dec 28, 2023
1 parent 6dcc464 commit 7d7d73a
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,18 @@ public boolean find(byte[] basicClass) {
case UTF8:
final int strLen = readUnsignedShort(index + 1, basicClass);
size = 3 + strLen;
label:
for (byte[] bytes : BYTES_TO_SEARCH) {
if (strLen == bytes.length) {
boolean found = true;
for (int j = index + 3; j < index + 3 + strLen; j++) {
if (basicClass[j] != bytes[j - (index + 3)]) {
break label;
found = false;
break;
}
}
return true;
if (found) {
return true;
}
}
}
break;
Expand Down

0 comments on commit 7d7d73a

Please sign in to comment.