From 7b16e75553e6a406f8ef868d12c8bc0a421f05aa Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 24 Aug 2016 14:48:29 -0400 Subject: [PATCH] v0.4.2: levels now precompute their length for better performance --- .../shatteredpixel/shatteredpixeldungeon/levels/Level.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java index 484ad862d..0cabab0a3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -105,6 +105,7 @@ public abstract class Level implements Bundlable { protected int width; protected int height; + protected int length; protected static final float TIME_TO_RESPAWN = 50; @@ -278,6 +279,7 @@ public abstract class Level implements Bundlable { protected void setupSize(){ width = height = 32; + length = width * height; } public void reset() { @@ -300,6 +302,7 @@ public abstract class Level implements Bundlable { height = bundle.getInt("height"); } else width = height = 32; //default sizes + length = width * height; PathFinder.setMapSize(width(), height()); mobs = new HashSet<>(); @@ -410,7 +413,7 @@ public abstract class Level implements Bundlable { } public int length() { - return width() * height(); + return length; } public String tilesTex() {