[Lldb-commits] [lldb] 6412258 - [lldb][NFCI] BreakpointResolverName ctor shouldn't unnecessarily copy data (#66001)

via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 12 15:32:11 PDT 2023


Author: Alex
Date: 2023-09-12T15:32:06-07:00
New Revision: 64122580c0809fc6fc15bd955fea4e9ace80a135

URL: https://github.com/llvm/llvm-project/commit/64122580c0809fc6fc15bd955fea4e9ace80a135
DIFF: https://github.com/llvm/llvm-project/commit/64122580c0809fc6fc15bd955fea4e9ace80a135.diff

LOG: [lldb][NFCI] BreakpointResolverName ctor shouldn't unnecessarily copy data (#66001)

Instead of creating a copy of the vector, we should just pass a
reference along. The only method that calls this Ctor also holds onto a
non-mutable reference to the vector of strings so a copy should be
unnecessary.

Added: 
    

Modified: 
    lldb/include/lldb/Breakpoint/BreakpointResolverName.h
    lldb/source/Breakpoint/BreakpointResolverName.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Breakpoint/BreakpointResolverName.h b/lldb/include/lldb/Breakpoint/BreakpointResolverName.h
index 7a9fc466076799a..cbfcbc9af0ea1cb 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointResolverName.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointResolverName.h
@@ -38,7 +38,7 @@ class BreakpointResolverName : public BreakpointResolver {
 
   // This one takes a C++ array of names.  It is always MatchType = Exact.
   BreakpointResolverName(const lldb::BreakpointSP &bkpt,
-                         std::vector<std::string> names,
+                         const std::vector<std::string> &names,
                          lldb::FunctionNameType name_type_mask,
                          lldb::LanguageType language, lldb::addr_t offset,
                          bool skip_prologue);

diff  --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp b/lldb/source/Breakpoint/BreakpointResolverName.cpp
index b533bdfb9c11ce5..861377a5ddabfb5 100644
--- a/lldb/source/Breakpoint/BreakpointResolverName.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp
@@ -56,12 +56,10 @@ BreakpointResolverName::BreakpointResolverName(
   }
 }
 
-BreakpointResolverName::BreakpointResolverName(const BreakpointSP &bkpt,
-                                               std::vector<std::string> names,
-                                               FunctionNameType name_type_mask,
-                                               LanguageType language,
-                                               lldb::addr_t offset,
-                                               bool skip_prologue)
+BreakpointResolverName::BreakpointResolverName(
+    const BreakpointSP &bkpt, const std::vector<std::string> &names,
+    FunctionNameType name_type_mask, LanguageType language, lldb::addr_t offset,
+    bool skip_prologue)
     : BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset),
       m_match_type(Breakpoint::Exact), m_language(language),
       m_skip_prologue(skip_prologue) {


        


More information about the lldb-commits mailing list