Permalink
Browse files

Using `indexOfObjectIdenticalTo` instead of `indexOfObject` in RCTUIM…

…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 9d9e250d28a6a4d1698ac02a1f905e20c5a66074
Showing with 2 additions and 2 deletions.
  1. +2 −2 React/Modules/RCTUIManager.m
@@ -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];
@@ -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];

0 comments on commit 9d9e250

Please sign in to comment.