mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 07:28:19 +01:00
Counted loop
This commit is contained in:
parent
1c9b6f3529
commit
cf1373396b
@ -38,9 +38,10 @@ final class TagHandlerImpl implements TagHandler {
|
|||||||
final var paths = tag.path;
|
final var paths = tag.path;
|
||||||
TagHandlerImpl[] pathHandlers = null;
|
TagHandlerImpl[] pathHandlers = null;
|
||||||
if (paths != null) {
|
if (paths != null) {
|
||||||
pathHandlers = new TagHandlerImpl[paths.length];
|
final int length = paths.length;
|
||||||
int in = 0;
|
pathHandlers = new TagHandlerImpl[length];
|
||||||
for (var path : paths) {
|
for (int i = 0; i < length; i++) {
|
||||||
|
final Tag.PathEntry path = paths[i];
|
||||||
final int pathIndex = path.index();
|
final int pathIndex = path.index();
|
||||||
if (pathIndex >= entries.length) {
|
if (pathIndex >= entries.length) {
|
||||||
if (value == null) return;
|
if (value == null) return;
|
||||||
@ -57,13 +58,13 @@ final class TagHandlerImpl implements TagHandler {
|
|||||||
local = handler;
|
local = handler;
|
||||||
} else throw new IllegalStateException("Cannot set a path-able tag on a non-path-able entry");
|
} else throw new IllegalStateException("Cannot set a path-able tag on a non-path-able entry");
|
||||||
entries = local.entries;
|
entries = local.entries;
|
||||||
pathHandlers[in++] = local;
|
pathHandlers[i] = local;
|
||||||
}
|
}
|
||||||
// Handle removal if the tag was present (recursively)
|
// Handle removal if the tag was present (recursively)
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
pathHandlers[in - 1].entries[tagIndex] = null;
|
pathHandlers[length - 1].entries[tagIndex] = null;
|
||||||
boolean empty = false;
|
boolean empty = false;
|
||||||
for (int i = in - 1; i >= 0; i--) {
|
for (int i = length - 1; i >= 0; i--) {
|
||||||
TagHandlerImpl handler = pathHandlers[i];
|
TagHandlerImpl handler = pathHandlers[i];
|
||||||
Entry<?>[] entr = handler.entries;
|
Entry<?>[] entr = handler.entries;
|
||||||
// Verify if the handler is empty
|
// Verify if the handler is empty
|
||||||
|
Loading…
Reference in New Issue
Block a user