[gnote] Move semantics for triehit



commit 090e96aa6de2d1405a7f2259f17c09acf5e22499
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sun Jun 19 18:13:59 2022 +0300

    Move semantics for triehit

 src/triehit.hpp  | 9 +++++----
 src/watchers.cpp | 5 +++--
 2 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/src/triehit.hpp b/src/triehit.hpp
index d8592e39..cac74b53 100644
--- a/src/triehit.hpp
+++ b/src/triehit.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2013,2017,2019 Aurimas Cernius
+ * Copyright (C) 2013,2017,2019,2022 Aurimas Cernius
  * Copyright (C) 2011 Debarshi Ray
  * Copyright (C) 2009 Hubert Figuiere
  *
@@ -23,6 +23,7 @@
 #define __TRIEHIT_HPP_
 
 #include <memory>
+#include <utility>
 
 #include <glibmm/ustring.h>
 
@@ -36,11 +37,11 @@ public:
   typedef std::vector<Ptr> List;
   typedef std::shared_ptr<List> ListPtr;
 
-  TrieHit(int s, int e, const Glib::ustring & k, const value_t & v)
+  TrieHit(int s, int e, Glib::ustring && k, value_t && v)
     : m_start(s)
     , m_end(e)
-    , m_key(k)
-    , m_value(v)
+    , m_key(std::forward<Glib::ustring>(k))
+    , m_value(std::forward<value_t>(v))
     {
     }
 
diff --git a/src/watchers.cpp b/src/watchers.cpp
index d4e71d2b..8b23faed 100644
--- a/src/watchers.cpp
+++ b/src/watchers.cpp
@@ -880,10 +880,11 @@ namespace gnote {
       if (idx < 0)
         break;
 
-      TrieHit<NoteBase::WeakPtr> hit(idx, idx + find_title_lower.length(), find_title_lower, find_note);
+      auto title_len = find_title_lower.length();
+      TrieHit<NoteBase::WeakPtr> hit(idx, idx + title_len, std::move(find_title_lower), find_note);
       do_highlight(note_manager, note, hit, start, end);
 
-      idx += find_title_lower.length();
+      idx += title_len;
     }
   }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]