From eab69404673332726925751d492f08934493bf67 Mon Sep 17 00:00:00 2001 From: Carlos Amengual Date: Wed, 18 Dec 2024 14:46:22 +0100 Subject: [PATCH] Small performance follow-up to 9b7b248226f --- .../java/io/sf/carte/echosvg/parser/AbstractParser.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/echosvg-parser/src/main/java/io/sf/carte/echosvg/parser/AbstractParser.java b/echosvg-parser/src/main/java/io/sf/carte/echosvg/parser/AbstractParser.java index e6b0a4936..1ca765946 100644 --- a/echosvg-parser/src/main/java/io/sf/carte/echosvg/parser/AbstractParser.java +++ b/echosvg-parser/src/main/java/io/sf/carte/echosvg/parser/AbstractParser.java @@ -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)) { @@ -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];