Fabric: Using non-mutating `at` instead of `[]` for `-[RCTSurfaceTouchHandler _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
This commit is contained in:
Valentin Shergin 2018-11-16 18:18:57 -08:00 committed by Facebook Github Bot
parent 1de79e12e1
commit 868406dbec
1 changed files with 2 additions and 2 deletions

View File

@ -196,14 +196,14 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithTarget:(id)target action:(SEL)action
- (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);
}