From 23615e1c9f7e322df981f0a3fa9119fe2e0e4507 Mon Sep 17 00:00:00 2001 From: md_5 Date: Tue, 28 Jan 2014 21:46:15 +1100 Subject: [PATCH] Use simpler iterator --- ...t-Threaded-Bulk-Chunk-Compression-and-Cachin.patch | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/CraftBukkit-Patches/0105-Implement-Threaded-Bulk-Chunk-Compression-and-Cachin.patch b/CraftBukkit-Patches/0105-Implement-Threaded-Bulk-Chunk-Compression-and-Cachin.patch index 07d05bf64b..57609480d7 100644 --- a/CraftBukkit-Patches/0105-Implement-Threaded-Bulk-Chunk-Compression-and-Cachin.patch +++ b/CraftBukkit-Patches/0105-Implement-Threaded-Bulk-Chunk-Compression-and-Cachin.patch @@ -1,4 +1,4 @@ -From 7acc085a95961261de6b3e68d46ec46e974a2c3b Mon Sep 17 00:00:00 2001 +From c1d148a1f2b801d24c81d9ffdbfb8669de69cc55 Mon Sep 17 00:00:00 2001 From: md_5 Date: Tue, 28 Jan 2014 20:32:07 +1100 Subject: [PATCH] Implement Threaded Bulk Chunk Compression and Caching @@ -79,10 +79,10 @@ index fb95be4..2875c94 100644 ServerConnection.a(this.a).add(networkmanager); diff --git a/src/main/java/org/spigotmc/ChunkCompressor.java b/src/main/java/org/spigotmc/ChunkCompressor.java new file mode 100644 -index 0000000..023900f +index 0000000..3fd45dc --- /dev/null +++ b/src/main/java/org/spigotmc/ChunkCompressor.java -@@ -0,0 +1,65 @@ +@@ -0,0 +1,64 @@ +package org.spigotmc; + +import java.util.Arrays; @@ -131,12 +131,11 @@ index 0000000..023900f + chunk.compress(); // Compress the chunk + byte[] buffer = Arrays.copyOf( chunk.buffer, chunk.size ); // Resize the array to correct sizing + -+ Iterator> iter = cache.entrySet().iterator(); // Grab a single iterator reference ++ Iterator iter = cache.values().iterator(); // Grab a single iterator reference + // Whilst this next entry is too big for us, and we have stuff to remove + while ( cacheSize + buffer.length > org.spigotmc.SpigotConfig.chunkCacheBytes && iter.hasNext() ) + { -+ Map.Entry entry = iter.next(); // Grab entry -+ cacheSize -= entry.getValue().length; // Update size table ++ cacheSize -= iter.next().length; // Update size table + iter.remove(); // Remove it alltogether + } + cacheSize += buffer.length; // Update size table