[Support] TrigramIndex::insert - pass std::String argument by const reference. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 23 Jan 2021 11:03:43 +0000 (11:03 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 23 Jan 2021 11:04:00 +0000 (11:04 +0000)
Avoid string copies and fix clang-tidy warning.

llvm/include/llvm/Support/TrigramIndex.h
llvm/lib/Support/TrigramIndex.cpp

index 360ab94..0be6a10 100644 (file)
@@ -38,7 +38,7 @@ class StringRef;
 class TrigramIndex {
  public:
   /// Inserts a new Regex into the index.
-  void insert(std::string Regex);
+  void insert(const std::string &Regex);
 
   /// Returns true, if special case list definitely does not have a line
   /// that matches the query. Returns false, if it's not sure.
index 1f1f302..4370adc 100644 (file)
@@ -25,7 +25,7 @@ static bool isAdvancedMetachar(unsigned Char) {
   return strchr(RegexAdvancedMetachars, Char) != nullptr;
 }
 
-void TrigramIndex::insert(std::string Regex) {
+void TrigramIndex::insert(const std::string &Regex) {
   if (Defeated) return;
   std::set<unsigned> Was;
   unsigned Cnt = 0;