@@ -71,10 +71,10 @@ Expected<CallSiteInfo> CallSiteInfo::decode(DataExtractor &Data,
7171
7272Error CallSiteInfoCollection::encode (FileWriter &O) const {
7373 O.writeU32 (CallSites.size ());
74- for (const CallSiteInfo &CSI : CallSites) {
74+ for (const CallSiteInfo &CSI : CallSites)
7575 if (Error Err = CSI.encode (O))
7676 return Err;
77- }
77+
7878 return Error::success ();
7979}
8080
@@ -175,23 +175,17 @@ Error CallSiteInfoLoader::loadYAML(std::vector<FunctionInfo> &Funcs,
175175
176176StringMap<FunctionInfo *>
177177CallSiteInfoLoader::buildFunctionMap (std::vector<FunctionInfo> &Funcs) {
178+ // If the function name is already in the map, don't update it. This way we
179+ // preferentially use the first encountered function. Since symbols are
180+ // loaded from dSYM first, we end up preferring keeping track of symbols
181+ // from dSYM rather than from the symbol table - which is what we want to
182+ // do.
178183 StringMap<FunctionInfo *> FuncMap;
179- auto insertFunc = [&](auto &Function) {
180- StringRef FuncName = GCreator.getString (Function.Name );
181- // If the function name is already in the map, don't update it. This way we
182- // preferentially use the first encountered function. Since symbols are
183- // loaded from dSYM first, we end up preferring keeping track of symbols
184- // from dSYM rather than from the symbol table - which is what we want to
185- // do.
186- if (FuncMap.count (FuncName))
187- return ;
188- FuncMap[FuncName] = &Function;
189- };
190184 for (auto &Func : Funcs) {
191- insertFunc ( Func);
192- if (Func.MergedFunctions . has_value () )
193- for (auto &MFunc : Func. MergedFunctions ->MergedFunctions )
194- insertFunc ( MFunc);
185+ FuncMap. try_emplace (GCreator. getString (Func. Name ), & Func);
186+ if (auto MFuncs = Func.MergedFunctions )
187+ for (auto &MFunc : MFuncs ->MergedFunctions )
188+ FuncMap. try_emplace (GCreator. getString (MFunc. Name ), & MFunc);
195189 }
196190 return FuncMap;
197191}
0 commit comments