diff options
author | Wesley Wolfe <weswolf@aol.com> | 2012-08-04 21:11:28 -0500 |
---|---|---|
committer | Wesley Wolfe <weswolf@aol.com> | 2012-08-04 21:11:28 -0500 |
commit | 9804665fec34c375c9f66cd756a96de9d57ed505 (patch) | |
tree | b4d83ba59b810de7fad4428a23f0534362ff8e8e /src/main/java/net/minecraft/server | |
parent | 14a470985df8bc3e507a9d6a6f6a64b734873ec9 (diff) | |
download | craftbukkit-9804665fec34c375c9f66cd756a96de9d57ed505.tar craftbukkit-9804665fec34c375c9f66cd756a96de9d57ed505.tar.gz craftbukkit-9804665fec34c375c9f66cd756a96de9d57ed505.tar.lz craftbukkit-9804665fec34c375c9f66cd756a96de9d57ed505.tar.xz craftbukkit-9804665fec34c375c9f66cd756a96de9d57ed505.zip |
Fix bounding box pool to use a dynamic cache size
Also changed insane array copy routine. This should reduce server lag
spikes that occur periodically.
Diffstat (limited to 'src/main/java/net/minecraft/server')
-rw-r--r-- | src/main/java/net/minecraft/server/AABBPool.java | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/main/java/net/minecraft/server/AABBPool.java b/src/main/java/net/minecraft/server/AABBPool.java index a5eeb2fb..8262e5c1 100644 --- a/src/main/java/net/minecraft/server/AABBPool.java +++ b/src/main/java/net/minecraft/server/AABBPool.java @@ -18,6 +18,8 @@ public class AABBPool { } public AxisAlignedBB a(double d0, double d1, double d2, double d3, double d4, double d5) { + if (this.f == 0) return new AxisAlignedBB(d0, d1, d2, d3, d4, d5); // CraftBukkit - don't pool objects indefinitely if thread doesn't adhere to contract + AxisAlignedBB axisalignedbb; if (this.d >= this.c.size()) { @@ -37,16 +39,19 @@ public class AABBPool { this.e = this.d; } - if (this.f++ == this.a) { - int i = Math.max(this.e, this.c.size() - this.b); - - while (this.c.size() > i) { - this.c.remove(i); + // CraftBukkit start - intelligent cache + if ((this.f++ & 0xff) == 0) { + int newSize = this.c.size() - (this.c.size() >> 3); + if (newSize > this.e) { // newSize will be 87.5%, but if we were not in that range, we clear some of the cache + for (int i = this.c.size() - 1; i > newSize; i--) { // Work down from size() to prevent insane array copies + this.c.remove(i); + } } this.e = 0; - this.f = 0; + // this.f = 0; // We do not reset to zero; it doubles for a flag } + // CraftBukkit end this.d = 0; } |