[llvm-ar] Simplify string table get-or-insert pattern with .insert, NFC

llvm-svn: 349681
This commit is contained in:
Reid Kleckner 2018-12-19 20:54:06 +00:00
parent ca6434de37
commit ed3ef41711
1 changed files with 4 additions and 6 deletions

View File

@ -268,14 +268,12 @@ static void printMemberHeader(raw_ostream &Out, uint64_t Pos,
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);