Fix issue where zero was returned on idential object array lookup

Reviewers: scottg, schneider, garrett

Reviewed By: garrett

Subscribers: jenkins

Differential Revision: https://phabricator.pinadmin.com/D84131
This commit is contained in:
Levi McCallum
2016-04-08 15:49:28 -07:00
parent 5e3091551e
commit 6f41d28dd0

View File

@@ -166,9 +166,13 @@ static inline void findNodesInLayoutAtIndexesWithFilteredNodes(ASLayout *layout,
while (idx != NSNotFound) {
ASDisplayNode *node = (ASDisplayNode *)layout.immediateSublayouts[idx].layoutableObject;
ASDisplayNodeCAssert(node, @"A flattened layout must consist exclusively of node sublayouts");
if (node != nil && [filteredNodes indexOfObjectIdenticalTo:node] != NSNotFound) {
[nodes addObject:node];
positions.push_back(idx);
// Ignore the odd case in which a non-node sublayout is accessed and the type cast fails
if (node != nil) {
BOOL notFiltered = (filteredNodes == nil || [filteredNodes indexOfObjectIdenticalTo:node] == NSNotFound);
if (notFiltered) {
[nodes addObject:node];
positions.push_back(idx);
}
}
idx = [indexes indexGreaterThanIndex:idx];
}