@@ -791,7 +791,7 @@ void StubHelperSection::writeTo(uint8_t *buf) const {
791791
792792void StubHelperSection::setUp () {
793793 Symbol *binder = symtab->addUndefined (" dyld_stub_binder" , /* file=*/ nullptr ,
794- /* isWeakRef=*/ false );
794+ /* isWeakRef=*/ false );
795795 if (auto *undefined = dyn_cast<Undefined>(binder))
796796 treatUndefinedSymbol (*undefined,
797797 " lazy binding (normally in libSystem.dylib)" );
@@ -1182,7 +1182,7 @@ void SymtabSection::emitObjectFileStab(ObjFile *file) {
11821182 StabsEntry stab (N_OSO);
11831183 stab.sect = target->cpuSubtype ;
11841184 SmallString<261 > path (!file->archiveName .empty () ? file->archiveName
1185- : file->getName ());
1185+ : file->getName ());
11861186 std::error_code ec = sys::fs::make_absolute (path);
11871187 if (ec)
11881188 fatal (" failed to get absolute path for " + path);
@@ -1540,24 +1540,17 @@ StringTableSection::StringTableSection()
15401540 : LinkEditSection(segment_names::linkEdit, section_names::stringTable) {}
15411541
15421542uint32_t StringTableSection::addString (StringRef str) {
1543- // If deduplication is disabled, just add the string
1544- if (!config->deduplicateSymbolStrings ) {
1545- uint32_t strx = size;
1546- strings.push_back (str);
1547- size += str.size () + 1 ; // +1 for null terminator
1548- return strx;
1549- }
1550-
1551- // Deduplicate strings
1552- llvm::CachedHashStringRef hashedStr (str);
1553- auto it = stringMap.find (hashedStr);
1554- if (it != stringMap.end ())
1555- return it->second ;
1556-
15571543 uint32_t strx = size;
1558- stringMap[hashedStr] = strx;
1544+ if (config->deduplicateSymbolStrings ) {
1545+ // Deduplicate strings
1546+ llvm::CachedHashStringRef hashedStr (str);
1547+ auto [it, inserted] = stringMap.try_emplace (hashedStr, strx);
1548+ if (!inserted)
1549+ return it->second ;
1550+ }
1551+
15591552 strings.push_back (str);
1560- size += str.size () + 1 ;
1553+ size += str.size () + 1 ; // +1 for null terminator
15611554 return strx;
15621555}
15631556
0 commit comments