@@ -92,11 +92,9 @@ parseTargetIDWithFormatCheckingOnly(llvm::StringRef TargetID,
92
92
if (Sign != ' +' && Sign != ' -' )
93
93
return std::nullopt;
94
94
bool IsOn = Sign == ' +' ;
95
- auto Loc = FeatureMap->find (Feature);
96
95
// 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 )
98
97
return std::nullopt;
99
- (*FeatureMap)[Feature] = IsOn;
100
98
Features = Splits.second ;
101
99
}
102
100
return Processor;
@@ -147,15 +145,15 @@ getConflictTargetIDCombination(const std::set<llvm::StringRef> &TargetIDs) {
147
145
struct Info {
148
146
llvm::StringRef TargetID;
149
147
llvm::StringMap<bool > Features;
148
+ Info (llvm::StringRef TargetID, const llvm::StringMap<bool > &Features)
149
+ : TargetID(TargetID), Features(Features) {}
150
150
};
151
151
llvm::StringMap<Info> FeatureMap;
152
152
for (auto &&ID : TargetIDs) {
153
153
llvm::StringMap<bool > Features;
154
154
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) {
159
157
auto &ExistingFeatures = Loc->second .Features ;
160
158
if (llvm::any_of (Features, [&](auto &F) {
161
159
return ExistingFeatures.count (F.first ()) == 0 ;
0 commit comments