[clang] Pass QualifiedRenameRule strings by reference to reduce copies (PR #69848)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 21 08:04:06 PDT 2023
https://github.com/mfdeakin created https://github.com/llvm/llvm-project/pull/69848
Fixes #34652
>From 0052d66e15451af47ebf8f2c4b060ea21a75f4a4 Mon Sep 17 00:00:00 2001
From: Michael Deakin <mfdeakin at cs.unc.edu>
Date: Thu, 19 Oct 2023 19:28:46 -0700
Subject: [PATCH] Pass QualifiedRenameRule strings by reference to reduce
copies
Fixes #34652
---
.../clang/Tooling/Refactoring/Rename/RenamingAction.h | 9 ++++-----
clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp | 4 ++--
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/clang/include/clang/Tooling/Refactoring/Rename/RenamingAction.h b/clang/include/clang/Tooling/Refactoring/Rename/RenamingAction.h
index 43a8d56e4e71762..1ac3ea1aa6e36d6 100644
--- a/clang/include/clang/Tooling/Refactoring/Rename/RenamingAction.h
+++ b/clang/include/clang/Tooling/Refactoring/Rename/RenamingAction.h
@@ -68,15 +68,14 @@ class RenameOccurrences final : public SourceChangeRefactoringRule {
class QualifiedRenameRule final : public SourceChangeRefactoringRule {
public:
- static Expected<QualifiedRenameRule> initiate(RefactoringRuleContext &Context,
- std::string OldQualifiedName,
- std::string NewQualifiedName);
+ static Expected<QualifiedRenameRule>
+ initiate(RefactoringRuleContext &Context, const std::string &OldQualifiedName,
+ std::string &&NewQualifiedName);
static const RefactoringDescriptor &describe();
private:
- QualifiedRenameRule(const NamedDecl *ND,
- std::string NewQualifiedName)
+ QualifiedRenameRule(const NamedDecl *ND, std::string &&NewQualifiedName)
: ND(ND), NewQualifiedName(std::move(NewQualifiedName)) {}
Expected<AtomicChanges>
diff --git a/clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp b/clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
index 72598601d47d679..ba17d0b807a775a 100644
--- a/clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
+++ b/clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
@@ -89,8 +89,8 @@ RenameOccurrences::createSourceReplacements(RefactoringRuleContext &Context) {
Expected<QualifiedRenameRule>
QualifiedRenameRule::initiate(RefactoringRuleContext &Context,
- std::string OldQualifiedName,
- std::string NewQualifiedName) {
+ const std::string &OldQualifiedName,
+ std::string &&NewQualifiedName) {
const NamedDecl *ND =
getNamedDeclFor(Context.getASTContext(), OldQualifiedName);
if (!ND)
More information about the cfe-commits
mailing list