Skip to content

Commit 5cce31e

Browse files
committed
Replace find + assign with try_emplace
1 parent 89c325c commit 5cce31e

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

cpp2rust/cpp_rule_preprocessor.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -774,13 +774,12 @@ int main(int argc, char *argv[]) {
774774
llvm::json::Object file_root;
775775
cpp2rust::Extract(path, file_root);
776776
for (auto &[k, v] : file_root) {
777-
if (root.find(k) != root.end()) {
777+
if (!root.try_emplace(k, std::move(v)).second) {
778778
llvm::errs() << "ERROR: rule name " << k.str()
779779
<< " defined in multiple files in " << dir.string()
780780
<< '\n';
781781
return EXIT_FAILURE;
782782
}
783-
root[k] = std::move(v);
784783
}
785784
}
786785

0 commit comments

Comments
 (0)