Use a dynamic pool size for the iterator cache

Many codepaths only end up with one iterator being used at a time and
most of the rest only get up to two being used so using a static pool of
three is wasteful. This also allows us to efficiently handle cases that
exceed 3 iterators in use. Overall this dramatically increases the hit rate
and results in less iterators being created.
This commit is contained in:
Travis Watkins
2012-08-19 19:59:58 -05:00
parent e7e643d83a
commit ccc760d629
2 changed files with 37 additions and 21 deletions

View File

@@ -111,11 +111,13 @@ public class PathfinderGoalSelector {
// CraftBukkit - switch order
if (!this.a(pathfindergoalselectoritem, pathfindergoalselectoritem1) && this.b.contains(pathfindergoalselectoritem1)) {
// this.c.b(); // CraftBukkit - not in production code
((UnsafeList.Itr) iterator).valid = false; // CraftBukkit - mark iterator for reuse
return false;
}
// CraftBukkit - switch order
} else if (!pathfindergoalselectoritem1.a.g() && this.b.contains(pathfindergoalselectoritem1)) {
// this.c.b(); // CraftBukkit - not in production code
((UnsafeList.Itr) iterator).valid = false; // CraftBukkit - mark iterator for reuse
return false;
}
}