Skip to content

Commit

Permalink
Using indexOfObjectIdenticalTo instead of indexOfObject in RCTUIM…
Browse files Browse the repository at this point in the history
…anager

Summary:
This should be much more performant (and it better illustrates the intension of the code).
The fix was suggested by Adlai-Holler.

Reviewed By: mmmulani

Differential Revision: D5851595

fbshipit-source-id: 45d172a5fa796549c6dcea8f35c5cbb2a4c2d2e0
  • Loading branch information
shergin authored and facebook-github-bot committed Sep 18, 2017
1 parent d7f6208 commit 9d9e250
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions React/Modules/RCTUIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ - (void)_removeChildren:(NSArray<UIView *> *)children
// So, let's temporary restore the view back after removing.
// To do so, we have to memorize original `superview` (which can differ from `container`) and an index of removed view.
UIView *originalSuperview = removedChild.superview;
NSUInteger originalIndex = [originalSuperview.subviews indexOfObject:removedChild];
NSUInteger originalIndex = [originalSuperview.subviews indexOfObjectIdenticalTo:removedChild];
[container removeReactSubview:removedChild];
[originalSuperview insertSubview:removedChild atIndex:originalIndex];

Expand Down Expand Up @@ -821,7 +821,7 @@ - (void)_removeChildren:(NSArray<UIView *> *)children
return;
}

NSUInteger indexOfView = [superShadowView.reactSubviews indexOfObject:shadowView];
NSUInteger indexOfView = [superShadowView.reactSubviews indexOfObjectIdenticalTo:shadowView];
RCTAssert(indexOfView != NSNotFound, @"View's superview doesn't claim it as subview (id %@)", reactTag);
NSArray<NSNumber *> *removeAtIndices = @[@(indexOfView)];
NSArray<NSNumber *> *addTags = @[newReactTag];
Expand Down

0 comments on commit 9d9e250

Please sign in to comment.