[llvm] r349681 - [llvm-ar] Simplify string table get-or-insert pattern with .insert, NFC
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 19 12:54:06 PST 2018
Author: rnk
Date: Wed Dec 19 12:54:06 2018
New Revision: 349681
URL: http://llvm.org/viewvc/llvm-project?rev=349681&view=rev
Log:
[llvm-ar] Simplify string table get-or-insert pattern with .insert, NFC
Modified:
llvm/trunk/lib/Object/ArchiveWriter.cpp
Modified: llvm/trunk/lib/Object/ArchiveWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ArchiveWriter.cpp?rev=349681&r1=349680&r2=349681&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ArchiveWriter.cpp (original)
+++ llvm/trunk/lib/Object/ArchiveWriter.cpp Wed Dec 19 12:54:06 2018
@@ -268,14 +268,12 @@ static void printMemberHeader(raw_ostrea
NamePos = StringTable.tell();
addToStringTable(StringTable, ArcName, M, Thin);
} else {
- StringMap<uint64_t>::const_iterator it = MemberNames.find(M.MemberName);
- if (it == MemberNames.end()) {
- NamePos = StringTable.tell();
+ auto Insertion = MemberNames.insert({M.MemberName, uint64_t(0)});
+ if (Insertion.second) {
+ Insertion.first->second = StringTable.tell();
addToStringTable(StringTable, ArcName, M, Thin);
- MemberNames[M.MemberName] = NamePos;
- } else {
- NamePos = it->second;
}
+ NamePos = Insertion.first->second;
}
printWithSpacePadding(Out, NamePos, 15);
printRestOfMemberHeader(Out, ModTime, M.UID, M.GID, M.Perms, Size);
More information about the llvm-commits
mailing list