Remove useless map lookup

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2021-09-15 17:45:09 +02:00
parent 0e8c07a811
commit aa33e2256c

View File

@ -156,7 +156,9 @@ public final class ThreadDispatcher {
while (true) {
final Chunk chunk = chunkUpdateQueue.pollFirst();
if (chunk == null) break;
updateChunk(chunk);
// Update chunk's thread
ChunkEntry chunkEntry = chunkEntryMap.get(chunk);
if (chunkEntry != null) chunkEntry.thread = retrieveThread(chunk);
this.chunkUpdateQueue.addLast(chunk);
if (++counter > size || System.currentTimeMillis() >= endTime)
break;
@ -201,14 +203,6 @@ public final class ThreadDispatcher {
return threads.get(threadId);
}
private void updateChunk(@NotNull Chunk chunk) {
ChunkEntry chunkEntry = chunkEntryMap.get(chunk);
if (chunkEntry == null) return;
Collection<ChunkEntry> chunks = threadChunkMap.get(chunkEntry.thread);
if (chunks == null || chunks.isEmpty()) return;
chunkEntry.thread = retrieveThread(chunk);
}
private void processLoadedChunks() {
Chunk chunk;
while ((chunk = chunkLoadRequests.poll()) != null) {