Browse Source

Avoid iterators for hot paths.

NathanSweet 5 years ago
parent
commit
068a554cc9

+ 2 - 2
spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Animation.java

@@ -65,8 +65,8 @@ public class Animation {
 		this.timelines = timelines;
 
 		timelineIds.clear();
-		for (Timeline timeline : timelines)
-			timelineIds.addAll(timeline.getPropertyIds());
+		for (int i = 0, n = timelines.size; i < n; i++)
+			timelineIds.addAll(timelines.get(i).getPropertyIds());
 	}
 
 	/** Returns true if this animation contains a timeline with any of the specified property IDs. **/

+ 5 - 2
spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java

@@ -294,8 +294,11 @@ public class Skeleton {
 	}
 
 	private void sortPathConstraintAttachment (Skin skin, int slotIndex, Bone slotBone) {
-		for (SkinEntry entry : skin.attachments.orderedItems())
-			if (entry.getSlotIndex() == slotIndex) sortPathConstraintAttachment(entry.getAttachment(), slotBone);
+		Object[] entries = skin.attachments.orderedItems().items;
+		for (int i = 0, n = skin.attachments.size; i < n; i++) {
+			SkinEntry entry = (SkinEntry)entries[i];
+			if (entry.slotIndex == slotIndex) sortPathConstraintAttachment(entry.attachment, slotBone);
+		}
 	}
 
 	private void sortPathConstraintAttachment (Attachment attachment, Bone slotBone) {