From cf1373396b3a8448a73a8dbb235c8258284a9272 Mon Sep 17 00:00:00 2001 From: themode Date: Mon, 28 Mar 2022 15:59:36 +0200 Subject: [PATCH] Counted loop --- .../net/minestom/server/tag/TagHandlerImpl.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/minestom/server/tag/TagHandlerImpl.java b/src/main/java/net/minestom/server/tag/TagHandlerImpl.java index 4d8dd51c4..cbf387810 100644 --- a/src/main/java/net/minestom/server/tag/TagHandlerImpl.java +++ b/src/main/java/net/minestom/server/tag/TagHandlerImpl.java @@ -38,9 +38,10 @@ final class TagHandlerImpl implements TagHandler { final var paths = tag.path; TagHandlerImpl[] pathHandlers = null; if (paths != null) { - pathHandlers = new TagHandlerImpl[paths.length]; - int in = 0; - for (var path : paths) { + final int length = paths.length; + pathHandlers = new TagHandlerImpl[length]; + for (int i = 0; i < length; i++) { + final Tag.PathEntry path = paths[i]; final int pathIndex = path.index(); if (pathIndex >= entries.length) { if (value == null) return; @@ -57,13 +58,13 @@ final class TagHandlerImpl implements TagHandler { local = handler; } else throw new IllegalStateException("Cannot set a path-able tag on a non-path-able entry"); entries = local.entries; - pathHandlers[in++] = local; + pathHandlers[i] = local; } // Handle removal if the tag was present (recursively) if (value == null) { - pathHandlers[in - 1].entries[tagIndex] = null; + pathHandlers[length - 1].entries[tagIndex] = null; boolean empty = false; - for (int i = in - 1; i >= 0; i--) { + for (int i = length - 1; i >= 0; i--) { TagHandlerImpl handler = pathHandlers[i]; Entry[] entr = handler.entries; // Verify if the handler is empty