[clang] Use try_emplace instead of insert when getting new identifier
authorserge-sans-paille <sguelton@mozilla.com>
Thu, 29 Dec 2022 15:24:58 +0000 (16:24 +0100)
committerserge-sans-paille <sguelton@mozilla.com>
Thu, 29 Dec 2022 20:40:21 +0000 (21:40 +0100)
This is both less verbose and slightly faster, according to:

https://llvm-compile-time-tracker.com/compare.php?from=d9ab3e82f30d646deff054230b0c742704a1cf26&to=73405077ad913f634797ffc7a7bbb110ac9cae99&stat=instructions:u

No functional change intended :-)

clang/include/clang/Basic/IdentifierTable.h

index f98ea48..1886b1d 100644 (file)
@@ -595,7 +595,7 @@ public:
   /// Return the identifier token info for the specified named
   /// identifier.
   IdentifierInfo &get(StringRef Name) {
-    auto &Entry = *HashTable.insert(std::make_pair(Name, nullptr)).first;
+    auto &Entry = *HashTable.try_emplace(Name, nullptr).first;
 
     IdentifierInfo *&II = Entry.second;
     if (II) return *II;