Skip to content

Commit

Permalink
_CPBlockExpression: replace loops with arrayByApplyingBlock: method
Browse files Browse the repository at this point in the history
  • Loading branch information
cacaodev committed Feb 4, 2016
1 parent 0327f6b commit d07d8f6
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions Foundation/CPPredicate/_CPBlockExpression.j
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,19 @@

- (id)expressionValueWithObject:(id)object context:(CPDictionary)context
{
var args = [];

[_arguments enumerateObjectsUsingBlock:function(exp, idx)
var args = [_arguments arrayByApplyingBlock:function(exp, _)
{
[args addObject:[exp expressionValueWithObject:object context:context]];
return [exp expressionValueWithObject:object context:context];
}];

return _block(object, args, context);
}

- (CPExpression)_expressionWithSubstitutionVariables:(CPDictionary)bindings
{
var args = [];

[_arguments enumerateObjectsUsingBlock:function(exp, idx)
var args = [_arguments arrayByApplyingBlock:function(exp, _)
{
[args addObject:[exp _expressionWithSubstitutionVariables:bindings]];
return [exp _expressionWithSubstitutionVariables:bindings];
}];

return [[_CPBlockExpression alloc] initWithBlock:_block arguments:args];
Expand Down

0 comments on commit d07d8f6

Please sign in to comment.