Skip to content

Commit e3aee72

Browse files
committed
Minor performance optimization for overgrowth check
1 parent 84f9ffd commit e3aee72

File tree

1 file changed

+8
-8
lines changed
  • src/mods/cropmod/org/gotti/wurmunlimited/mods/cropmod

1 file changed

+8
-8
lines changed

src/mods/cropmod/org/gotti/wurmunlimited/mods/cropmod/CropMod.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,14 @@ public void init() {
120120
ctPollCropTiles.instrument(new ExprEditor() {
121121
public void edit(MethodCall methodCall) throws CannotCompileException {
122122
if (methodCall.getClassName().equals("com.wurmonline.server.zones.CropTilePoller") && methodCall.getMethodName().equals("checkForFarmGrowth")) {
123-
String replaceString = "if (((data >> 4) & 0x7) == 6) {\n";
124-
// Now for the removal, and the else clause to call checkForFarmGrowth on younger tiles...
125-
replaceString += " toRemove.add(cTile);\n" + "}\n"
126-
+ "else {\n"
127-
+ " checkForFarmGrowth(currTileId, cTile.getX(), cTile.getY(), type, (byte)data, meshToUse, cTile.isOnSurface());\n"
128-
+ "}\n"
129-
+ "$_ = null;";
130-
methodCall.replace(replaceString);
123+
StringBuffer code = new StringBuffer();
124+
code.append("if (((data >> 4) & 0x7) == 6) {\n");
125+
code.append(" toRemove.add(cTile);\n");
126+
code.append(" $_ = null;\n");
127+
code.append("} else {\n");
128+
code.append(" $_ = $proceed($$);\n");
129+
code.append("}\n");
130+
methodCall.replace(code.toString());
131131
}
132132
}
133133
});

0 commit comments

Comments
 (0)