From b86089c680a34a1680cf87380897d85204f33ab5 Mon Sep 17 00:00:00 2001 From: sullis Date: Tue, 23 Apr 2024 15:35:02 -0700 Subject: [PATCH] reduce enum array allocation --- .../java/org/apache/johnzon/core/JsonStreamParserImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/johnzon-core/src/main/java/org/apache/johnzon/core/JsonStreamParserImpl.java b/johnzon-core/src/main/java/org/apache/johnzon/core/JsonStreamParserImpl.java index b4eb5542..151a909f 100644 --- a/johnzon-core/src/main/java/org/apache/johnzon/core/JsonStreamParserImpl.java +++ b/johnzon-core/src/main/java/org/apache/johnzon/core/JsonStreamParserImpl.java @@ -34,6 +34,8 @@ //This class represents either the Json tokenizer and the Json parser. public class JsonStreamParserImpl extends JohnzonJsonParserImpl implements JsonChars { + private static final Event[] EVENT_VALUES = Event.values(); + private final boolean autoAdjust; //the main buffer where the stream will be buffered @@ -384,8 +386,8 @@ protected final char readNextNonWhitespaceChar(char c) { @Override public Event currentEvent() { - return previousEvent >= 0 && previousEvent < Event.values().length - ? Event.values()[previousEvent] + return previousEvent >= 0 && previousEvent < EVENT_VALUES.length + ? EVENT_VALUES[previousEvent] : null; }