@@ -92,11 +92,9 @@ parseTargetIDWithFormatCheckingOnly(llvm::StringRef TargetID,
9292 if (Sign != ' +' && Sign != ' -' )
9393 return std::nullopt ;
9494 bool IsOn = Sign == ' +' ;
95- auto Loc = FeatureMap->find (Feature);
9695 // Each feature can only show up at most once in target ID.
97- if (Loc != FeatureMap->end () )
96+ if (! FeatureMap->try_emplace (Feature, IsOn). second )
9897 return std::nullopt ;
99- (*FeatureMap)[Feature] = IsOn;
10098 Features = Splits.second ;
10199 }
102100 return Processor;
@@ -147,15 +145,15 @@ getConflictTargetIDCombination(const std::set<llvm::StringRef> &TargetIDs) {
147145 struct Info {
148146 llvm::StringRef TargetID;
149147 llvm::StringMap<bool > Features;
148+ Info (llvm::StringRef TargetID, const llvm::StringMap<bool > &Features)
149+ : TargetID(TargetID), Features(Features) {}
150150 };
151151 llvm::StringMap<Info> FeatureMap;
152152 for (auto &&ID : TargetIDs) {
153153 llvm::StringMap<bool > Features;
154154 llvm::StringRef Proc = *parseTargetIDWithFormatCheckingOnly (ID, &Features);
155- auto Loc = FeatureMap.find (Proc);
156- if (Loc == FeatureMap.end ())
157- FeatureMap[Proc] = Info{ID, Features};
158- else {
155+ auto [Loc, Inserted] = FeatureMap.try_emplace (Proc, ID, Features);
156+ if (!Inserted) {
159157 auto &ExistingFeatures = Loc->second .Features ;
160158 if (llvm::any_of (Features, [&](auto &F) {
161159 return ExistingFeatures.count (F.first ()) == 0 ;
0 commit comments