Skip to content

Commit

Permalink
Fabric: Using non-mutating at instead of [] for `-[RCTSurfaceTouc…
Browse files Browse the repository at this point in the history
…hHandler _activeTouches]`

Summary: Every C++ engineer (except me several months ago) knows that `operator []` can mutate the collection (Yeah! Don't ask), so this is especially dangerous if your hash function is broken (see the previous diff).

Reviewed By: mdvacca

Differential Revision: D13072805

fbshipit-source-id: 4436a8ff12fb27a57bfb6ee0ff986d7a9a825549
  • Loading branch information
shergin authored and facebook-github-bot committed Nov 17, 2018
1 parent 1de79e1 commit 868406d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions React/Fabric/RCTSurfaceTouchHandler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,14 @@ - (void)_registerTouches:(NSSet<UITouch *> *)touches
- (void)_updateTouches:(NSSet<UITouch *> *)touches
{
for (UITouch *touch in touches) {
UpdateActiveTouchWithUITouch(_activeTouches[touch], touch, _rootComponentView);
UpdateActiveTouchWithUITouch(_activeTouches.at(touch), touch, _rootComponentView);
}
}

- (void)_unregisterTouches:(NSSet<UITouch *> *)touches
{
for (UITouch *touch in touches) {
const auto &activeTouch = _activeTouches[touch];
const auto &activeTouch = _activeTouches.at(touch);
_identifierPool.enqueue(activeTouch.touch.identifier);
_activeTouches.erase(touch);
}
Expand Down

0 comments on commit 868406d

Please sign in to comment.