From 14bd9e494a555a498c62ef1682b1ab1b5e3f0eb7 Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Tue, 11 Nov 2014 17:41:29 +0100 Subject: [PATCH] Avoid allocation when bone cache size goes down then back up later. --- spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java b/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java index 1961d7e9b..4309c3c36 100644 --- a/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java +++ b/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java @@ -117,16 +117,16 @@ public class Skeleton { /** Caches information about bones and IK constraints. Must be called if bones or IK constraints are added or removed. */ public void updateCache () { + Array bones = this.bones; Array> boneCache = this.boneCache; Array ikConstraints = this.ikConstraints; int ikConstraintsCount = ikConstraints.size; int arrayCount = ikConstraintsCount + 1; - boneCache.truncate(arrayCount); - for (int i = 0, n = boneCache.size; i < n; i++) - boneCache.get(i).clear(); while (boneCache.size < arrayCount) boneCache.add(new Array()); + for (int i = 0; i < arrayCount; i++) + boneCache.get(i).clear(); Array nonIkBones = boneCache.first(); @@ -164,7 +164,7 @@ public class Skeleton { } Array> boneCache = this.boneCache; Array ikConstraints = this.ikConstraints; - int i = 0, last = boneCache.size - 1; + int i = 0, last = ikConstraints.size; while (true) { Array updateBones = boneCache.get(i); for (int ii = 0, nn = updateBones.size; ii < nn; ii++)