mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 16:37:38 +01:00
Use a for-each loop, and prevent iterator allocation when empty
This commit is contained in:
parent
051fbcb34b
commit
0c0b387345
@ -133,15 +133,18 @@ public abstract class ThreadProvider {
|
|||||||
if (!ChunkUtils.isLoaded(chunk))
|
if (!ChunkUtils.isLoaded(chunk))
|
||||||
return;
|
return;
|
||||||
chunk.tick(time);
|
chunk.tick(time);
|
||||||
chunkEntry.entities.forEach(entity -> {
|
final var entities = chunkEntry.entities;
|
||||||
final boolean hasQueue = lock.hasQueuedThreads();
|
if (!entities.isEmpty()) {
|
||||||
if (hasQueue) {
|
for (Entity entity : entities) {
|
||||||
lock.unlock();
|
final boolean hasQueue = lock.hasQueuedThreads();
|
||||||
// #acquire callbacks should be called here
|
if (hasQueue) {
|
||||||
lock.lock();
|
lock.unlock();
|
||||||
|
// #acquire callbacks should be called here
|
||||||
|
lock.lock();
|
||||||
|
}
|
||||||
|
entity.tick(time);
|
||||||
}
|
}
|
||||||
entity.tick(time);
|
}
|
||||||
});
|
|
||||||
});
|
});
|
||||||
Acquirable.refreshEntries(Collections.emptySet());
|
Acquirable.refreshEntries(Collections.emptySet());
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
Loading…
Reference in New Issue
Block a user