From 8669277b3bd4936cd23995242bfb8d5c4f5d2997 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Thu, 3 Mar 2022 09:22:32 -0800 Subject: [PATCH] Use std::unordered_set::find instead of std::unordered_set::contains Summary: changelog: [internal] I'm looking into JS exceptions in React 18 on Android and I've noticed we use [std::unordered_set::contains]((https://en.cppreference.com/w/cpp/container/unordered_set/contains) that is only supported in C++20. I don't think this causes the exceptions but I would like to eliminate this option. Reviewed By: javache Differential Revision: D34547741 fbshipit-source-id: 6cffcff3366e7579a2c0e19bc01ffcb355b9ddb6 --- .../com/facebook/react/fabric/jni/FabricMountingManager.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/FabricMountingManager.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/FabricMountingManager.cpp index fd24de61066689..7f67fe23c67071 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/FabricMountingManager.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/FabricMountingManager.cpp @@ -403,7 +403,8 @@ void FabricMountingManager::executeMount( bool revisionCheck = noRevisionCheck || newChildShadowView.props->revision > 1; bool allocationCheck = - !allocatedViewTags.contains(newChildShadowView.tag); + allocatedViewTags.find(newChildShadowView.tag) == + allocatedViewTags.end(); bool shouldCreateView = shouldRememberAllocatedViews_ ? allocationCheck : revisionCheck; if (shouldCreateView) { @@ -822,7 +823,7 @@ void FabricMountingManager::preallocateShadowView( return; } auto &allocatedViews = allocatedViewsIterator->second; - if (allocatedViews.contains(shadowView.tag)) { + if (allocatedViews.find(shadowView.tag) != allocatedViews.end()) { return; } allocatedViews.insert(shadowView.tag);