@@ -258,11 +258,9 @@ void CodeGenSchedModels::checkSTIPredicates() const {
258
258
// There cannot be multiple declarations with the same name.
259
259
for (const Record *R : Records.getAllDerivedDefinitions (" STIPredicateDecl" )) {
260
260
StringRef Name = R->getValueAsString (" Name" );
261
- const auto It = Declarations.find (Name);
262
- if (It == Declarations.end ()) {
263
- Declarations[Name] = R;
261
+ const auto [It, Inserted] = Declarations.try_emplace (Name, R);
262
+ if (Inserted)
264
263
continue ;
265
- }
266
264
267
265
PrintError (R->getLoc (), " STIPredicate " + Name + " multiply declared." );
268
266
PrintFatalNote (It->second ->getLoc (), " Previous declaration was here." );
@@ -417,9 +415,9 @@ void CodeGenSchedModels::collectSTIPredicates() {
417
415
for (const Record *R : Records.getAllDerivedDefinitions (" STIPredicate" )) {
418
416
const Record *Decl = R->getValueAsDef (" Declaration" );
419
417
420
- const auto It = Decl2Index. find (Decl);
421
- if (It == Decl2Index.end ()) {
422
- Decl2Index[Decl] = STIPredicates. size ();
418
+ const auto [It, Inserted] =
419
+ Decl2Index.try_emplace (Decl, STIPredicates. size ());
420
+ if (Inserted) {
423
421
STIPredicateFunction Predicate (Decl);
424
422
Predicate.addDefinition (R);
425
423
STIPredicates.emplace_back (std::move (Predicate));
0 commit comments