diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2012-10-24 22:53:23 -0500 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2012-10-27 22:19:03 -0400 |
commit | 60819c6693daf19dde68b04af38a4fee8c7da988 (patch) | |
tree | e7bd96a07f0e9d9f1f6b2721ddd1bb5dd71eaf48 /src/main/java/net/minecraft/server/AABBPool.java | |
parent | b9a72531b6e2ccc84bd021bca421255a957d96f7 (diff) | |
download | craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.tar craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.tar.gz craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.tar.lz craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.tar.xz craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.zip |
Update CraftBukkit to Minecraft 1.4(.2).
Diffstat (limited to 'src/main/java/net/minecraft/server/AABBPool.java')
-rw-r--r-- | src/main/java/net/minecraft/server/AABBPool.java | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/src/main/java/net/minecraft/server/AABBPool.java b/src/main/java/net/minecraft/server/AABBPool.java index 8262e5c1..0815fbd1 100644 --- a/src/main/java/net/minecraft/server/AABBPool.java +++ b/src/main/java/net/minecraft/server/AABBPool.java @@ -7,10 +7,10 @@ public class AABBPool { private final int a; private final int b; - private final List c = new ArrayList(); + private final List pool = new ArrayList(); private int d = 0; - private int e = 0; - private int f = 0; + private int largestSize = 0; + private int resizeTime = 0; public AABBPool(int i, int j) { this.a = i; @@ -18,15 +18,15 @@ 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 - + // CraftBukkit - don't pool objects indefinitely if thread doesn't adhere to contract + if (this.resizeTime == 0) return new AxisAlignedBB(d0, d1, d2, d3, d4, d5); AxisAlignedBB axisalignedbb; - if (this.d >= this.c.size()) { + if (this.d >= this.pool.size()) { axisalignedbb = new AxisAlignedBB(d0, d1, d2, d3, d4, d5); - this.c.add(axisalignedbb); + this.pool.add(axisalignedbb); } else { - axisalignedbb = (AxisAlignedBB) this.c.get(this.d); + axisalignedbb = (AxisAlignedBB) this.pool.get(this.d); axisalignedbb.b(d0, d1, d2, d3, d4, d5); } @@ -35,24 +35,34 @@ public class AABBPool { } public void a() { - if (this.d > this.e) { - this.e = this.d; + if (this.d > this.largestSize) { + this.largestSize = this.d; } // 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); + if ((this.resizeTime++ & 0xff) == 0) { + int newSize = this.pool.size() - (this.pool.size() >> 3); + // newSize will be 87.5%, but if we were not in that range, we clear some of the cache + if (newSize > this.largestSize) { + // Work down from size() to prevent insane array copies + for (int i = this.pool.size() - 1; i > newSize; i--) { + this.pool.remove(i); } } - this.e = 0; - // this.f = 0; // We do not reset to zero; it doubles for a flag + this.largestSize = 0; + // this.resizeTime = 0; // We do not reset to zero; it doubles for a flag } // CraftBukkit end this.d = 0; } + + public int c() { + return this.pool.size(); + } + + public int d() { + return this.d; + } } |