From c550cd7afba54c0996273d82eb4b050edfeb41c9 Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Sun, 10 Mar 2013 13:09:24 +0000 Subject: [PATCH] New: optimise CPArray enumerateObjectsWithOptions:usingBlock:. --- Foundation/CPArray/_CPArray.j | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Foundation/CPArray/_CPArray.j b/Foundation/CPArray/_CPArray.j index 8d8e1fd9a..98759ea44 100755 --- a/Foundation/CPArray/_CPArray.j +++ b/Foundation/CPArray/_CPArray.j @@ -631,8 +631,6 @@ var concat = Array.prototype.concat, - (void)enumerateObjectsWithOptions:(CPEnumerationOptions)options usingBlock:(Function /*(id anObject, int idx, @ref BOOL stop)*/)aFunction { - var shouldStop = NO; - if (options & CPEnumerationReverse) { var index = [self count] - 1, @@ -646,9 +644,12 @@ var concat = Array.prototype.concat, increment = 1; } + var shouldStop = NO, + shouldStopRef = @ref(shouldStop); + for (; index !== stop; index += increment) { - aFunction([self objectAtIndex:index], index, @ref(shouldStop)); + aFunction([self objectAtIndex:index], index, shouldStopRef); if (shouldStop) return;