Skip to content

Commit

Permalink
Small performance follow-up to 9b7b248
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosame committed Dec 18, 2024
1 parent 004b713 commit eab6940
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ void handleCalc() throws IOException {
char[] calcUCRef = { 'A', 'L', 'C', '(' };
char[] calcBuf = new char[4];

// For performance, ignore how many bytes were read
reader.read(calcBuf);

if (equalsAny(calcLCRef, calcUCRef, calcBuf)) {
Expand All @@ -393,10 +394,8 @@ void handleCalc() throws IOException {
}

private static boolean equalsAny(char[] lcRef, char[] ucRef, char[] buf) {
// Assume that lcRef and ucRef have the same length
if (lcRef.length != buf.length) {
return false;
}
// It's up to the caller to make sure that buf, lcRef and ucRef have the same length
assert lcRef.length == buf.length;

for (int i = 0; i < lcRef.length; i++) {
char c = buf[i];
Expand Down

0 comments on commit eab6940

Please sign in to comment.