Author: Kazu Hirata Date: 2024-10-08T07:28:53-07:00 New Revision: a8289a35d06b9f7cb3d9b18dba6be0f1f0a8a898
URL: https://github.com/llvm/llvm-project/commit/a8289a35d06b9f7cb3d9b18dba6be0f1f0a8a898 DIFF: https://github.com/llvm/llvm-project/commit/a8289a35d06b9f7cb3d9b18dba6be0f1f0a8a898.diff LOG: [Tooling] Avoid repeated hash lookups (NFC) (#111469) Added: Modified: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp Removed: ################################################################################ diff --git a/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp b/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp index 4313da66efc0b7..0cb96097415ea8 100644 --- a/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp +++ b/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp @@ -320,12 +320,9 @@ HeaderIncludes::HeaderIncludes(StringRef FileName, StringRef Code, // - If CategoryEndOffset[Priority] isn't set, use the next higher value // that is set, up to CategoryEndOffset[Highest]. auto Highest = Priorities.begin(); - if (CategoryEndOffsets.find(*Highest) == CategoryEndOffsets.end()) { - if (FirstIncludeOffset >= 0) - CategoryEndOffsets[*Highest] = FirstIncludeOffset; - else - CategoryEndOffsets[*Highest] = MinInsertOffset; - } + auto [It, Inserted] = CategoryEndOffsets.try_emplace(*Highest); + if (Inserted) + It->second = FirstIncludeOffset >= 0 ? FirstIncludeOffset : MinInsertOffset; // By this point, CategoryEndOffset[Highest] is always set appropriately: // - to an appropriate location before/after existing #includes, or // - to right after the header guard, or _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits