From 0b6b4bc5e3d7ebb6cc276f4d558aa1b7b8413a44 Mon Sep 17 00:00:00 2001 From: Jérémy Zurcher Date: Mon, 4 Jan 2016 17:11:22 +0100 Subject: PathIterator: do not compute size all the time --- core/src/ch/asynk/rustanddust/engine/PathIterator.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'core/src/ch/asynk/rustanddust') diff --git a/core/src/ch/asynk/rustanddust/engine/PathIterator.java b/core/src/ch/asynk/rustanddust/engine/PathIterator.java index 39b3db4e..099c65e9 100644 --- a/core/src/ch/asynk/rustanddust/engine/PathIterator.java +++ b/core/src/ch/asynk/rustanddust/engine/PathIterator.java @@ -17,6 +17,7 @@ public class PathIterator implements Iterator private Vector2 pos = new Vector2(); private Vector3 v = new Vector3(); private int i; + private int s; private List path; public PathIterator(Pawn pawn, Tile from, Tile to, Orientation orientation, List path) @@ -30,12 +31,12 @@ public class PathIterator implements Iterator this.o = pawn.getOrientation(); this.v.set(pawn.getPosition().x, pawn.getPosition().y, o.r()); this.i = 0; + this.s = path.size(); } @Override public boolean hasNext() { - int s = path.size(); if ((rotation || (i > s)) && (o == orientation)) return false; return true; @@ -47,8 +48,6 @@ public class PathIterator implements Iterator if (!hasNext()) throw new java.util.NoSuchElementException(); - int s = path.size(); - if (rotation || (i > s)) { v.z = orientation.r(); o = orientation; -- cgit v1.2.3