Permalink
Browse files

removed more allocations

  • Loading branch information...
PrimaryFeather committed Dec 2, 2011
1 parent f31575c commit d465035a357fed36c14c8d387657782ae77fbb26
Showing with 9 additions and 8 deletions.
  1. +9 −8 starling/src/starling/animation/Juggler.as
@@ -67,6 +67,7 @@ package starling.animation
/** Removes an object from the juggler. */
public function remove(object:IAnimatable):void
{
+ if (object == null) return;
var numObjects:int = mObjects.length;
for (var i:int=numObjects-1; i>=0; --i)
@@ -78,20 +79,20 @@ package starling.animation
public function removeTweens(target:Object):void
{
if (target == null) return;
+ var numObjects:int = mObjects.length;
- mObjects = mObjects.filter(
- function(currentObject:Object, index:int, vector:Vector.<Object>):Boolean
- {
- var tween:Tween = currentObject as Tween;
- if (tween && tween.target == target) return false;
- else return true;
- });
+ for (var i:int=numObjects-1; i>=0; --i)
+ {
+ var tween:Tween = mObjects[i] as Tween;
+ if (tween && tween.target == target)
+ mObjects.splice(i, 1);
+ }
}
/** Removes all objects at once. */
public function purge():void
{
- mObjects = new <IAnimatable>[];
+ mObjects.length = 0;
}
/** Delays the execution of a function until a certain time has passed. Creates an

0 comments on commit d465035

Please sign in to comment.