mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-02 11:22:01 +01:00
Use simpler iterator
By: md_5 <git@md-5.net>
This commit is contained in:
parent
3f8acf3f09
commit
6fd6437d95
@ -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 <git@md-5.net>
|
From: md_5 <git@md-5.net>
|
||||||
Date: Tue, 28 Jan 2014 20:32:07 +1100
|
Date: Tue, 28 Jan 2014 20:32:07 +1100
|
||||||
Subject: [PATCH] Implement Threaded Bulk Chunk Compression and Caching
|
Subject: [PATCH] Implement Threaded Bulk Chunk Compression and Caching
|
||||||
@ -79,10 +79,10 @@ index fb95be4..2875c94 100644
|
|||||||
ServerConnection.a(this.a).add(networkmanager);
|
ServerConnection.a(this.a).add(networkmanager);
|
||||||
diff --git a/src/main/java/org/spigotmc/ChunkCompressor.java b/src/main/java/org/spigotmc/ChunkCompressor.java
|
diff --git a/src/main/java/org/spigotmc/ChunkCompressor.java b/src/main/java/org/spigotmc/ChunkCompressor.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..023900f
|
index 0000000..3fd45dc
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/org/spigotmc/ChunkCompressor.java
|
+++ b/src/main/java/org/spigotmc/ChunkCompressor.java
|
||||||
@@ -0,0 +1,65 @@
|
@@ -0,0 +1,64 @@
|
||||||
+package org.spigotmc;
|
+package org.spigotmc;
|
||||||
+
|
+
|
||||||
+import java.util.Arrays;
|
+import java.util.Arrays;
|
||||||
@ -131,12 +131,11 @@ index 0000000..023900f
|
|||||||
+ chunk.compress(); // Compress the chunk
|
+ chunk.compress(); // Compress the chunk
|
||||||
+ byte[] buffer = Arrays.copyOf( chunk.buffer, chunk.size ); // Resize the array to correct sizing
|
+ byte[] buffer = Arrays.copyOf( chunk.buffer, chunk.size ); // Resize the array to correct sizing
|
||||||
+
|
+
|
||||||
+ Iterator<Map.Entry<Integer, byte[]>> iter = cache.entrySet().iterator(); // Grab a single iterator reference
|
+ Iterator<byte[]> iter = cache.values().iterator(); // Grab a single iterator reference
|
||||||
+ // Whilst this next entry is too big for us, and we have stuff to remove
|
+ // 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() )
|
+ while ( cacheSize + buffer.length > org.spigotmc.SpigotConfig.chunkCacheBytes && iter.hasNext() )
|
||||||
+ {
|
+ {
|
||||||
+ Map.Entry<Integer, byte[]> entry = iter.next(); // Grab entry
|
+ cacheSize -= iter.next().length; // Update size table
|
||||||
+ cacheSize -= entry.getValue().length; // Update size table
|
|
||||||
+ iter.remove(); // Remove it alltogether
|
+ iter.remove(); // Remove it alltogether
|
||||||
+ }
|
+ }
|
||||||
+ cacheSize += buffer.length; // Update size table
|
+ cacheSize += buffer.length; // Update size table
|
||||||
|
Loading…
Reference in New Issue
Block a user