Skip to content

Commit 4acfeaf

Browse files
[Tooling] Avoid repeated hash lookups (NFC) (#131264)
1 parent 0f98d1b commit 4acfeaf

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

clang/lib/Tooling/RefactoringCallbacks.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,14 @@ void ReplaceNodeWithTemplate::run(
220220
}
221221
}
222222
}
223-
if (NodeMap.count(FromId) == 0) {
223+
auto It = NodeMap.find(FromId);
224+
if (It == NodeMap.end()) {
224225
llvm::errs() << "Node to be replaced " << FromId
225226
<< " not bound in query.\n";
226227
llvm::report_fatal_error("FromId node not bound in MatchResult");
227228
}
228229
auto Replacement =
229-
tooling::Replacement(*Result.SourceManager, &NodeMap.at(FromId), ToText,
230+
tooling::Replacement(*Result.SourceManager, &It->second, ToText,
230231
Result.Context->getLangOpts());
231232
llvm::Error Err = Replace.add(Replacement);
232233
if (Err) {

0 commit comments

Comments
 (0)