Optimize entity AI goal selector

Remove redundant ArrayList to avoid excessive object creation and CPU
overhead, the entries are added to the list then immediately iterated through
to run so just run them directly.

Swap order of some conditionals to perform the more efficient check first
as if it fails the list lookup will not be executed.

Remove profiling hooks including some rather expensive calls to getSimpleName.
This commit is contained in:
Travis Watkins
2012-08-17 16:25:19 -05:00
parent 858d36efc9
commit d628c886d2
2 changed files with 31 additions and 24 deletions

View File

@@ -470,7 +470,7 @@ public abstract class EntityLiving extends Entity {
}
this.av += (f3 - this.av) * 0.3F;
this.world.methodProfiler.a("headTurn");
// this.world.methodProfiler.a("headTurn"); // CraftBukkit - not in production code
if (this.aV()) {
this.senses.a();
} else {
@@ -498,8 +498,8 @@ public abstract class EntityLiving extends Entity {
}
}
this.world.methodProfiler.b();
this.world.methodProfiler.a("rangeChecks");
// this.world.methodProfiler.b(); // CraftBukkit - not in production code
// this.world.methodProfiler.a("rangeChecks"); // CraftBukkit - not in production code
while (this.yaw - this.lastYaw < -180.0F) {
this.lastYaw -= 360.0F;
@@ -533,7 +533,7 @@ public abstract class EntityLiving extends Entity {
this.at += 360.0F;
}
this.world.methodProfiler.b();
// this.world.methodProfiler.b(); // CraftBukkit - not in production code
this.aw += f2;
}