================
@@ -86,9 +86,7 @@ void ObjCPropertyAttributeOrderFixer::sortPropertyAttributes(
       Value = Tok->TokenText;
     }
 
-    auto It = SortOrderMap.find(Attribute);
-    if (It == SortOrderMap.end())
-      It = SortOrderMap.insert({Attribute, SortOrderMap.size()}).first;
+    auto It = SortOrderMap.try_emplace(Attribute, SortOrderMap.size()).first;
 
     // Sort the indices based on the priority stored in `SortOrderMap`.
     const auto Ordinal = It->second;
----------------
owenca wrote:

My preference:
```suggestion
    // Sort the indices based on the priority stored in `SortOrderMap`.
    const auto Ordinal =
        SortOrderMap.try_emplace(Attribute, SortOrderMap.size()).first->second;
```
And delete lines 89-91.

https://github.com/llvm/llvm-project/pull/107962
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to