[gnote] More move semantics



commit d112f9db31444bd29857b10f2976fc39a6e49545
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sun May 22 22:49:40 2022 +0300

    More move semantics

 src/note.cpp                      | 4 ++--
 src/notebase.cpp                  | 4 ++--
 src/notebase.hpp                  | 4 ++--
 src/notemanager.cpp               | 6 +++---
 src/notemanager.hpp               | 2 +-
 src/notemanagerbase.cpp           | 2 +-
 src/notemanagerbase.hpp           | 2 +-
 src/synchronization/syncutils.cpp | 2 +-
 src/test/testnote.cpp             | 6 +++---
 src/test/testnote.hpp             | 4 ++--
 src/test/testnotemanager.cpp      | 6 +++---
 src/test/testnotemanager.hpp      | 2 +-
 12 files changed, 22 insertions(+), 22 deletions(-)
---
diff --git a/src/note.cpp b/src/note.cpp
index 00af23ee..2da83103 100644
--- a/src/note.cpp
+++ b/src/note.cpp
@@ -135,8 +135,8 @@ namespace gnote {
 
   const int  NoteData::s_noPosition = -1;
 
-  NoteData::NoteData(const Glib::ustring & _uri)
-    : m_uri(_uri)
+  NoteData::NoteData(Glib::ustring && _uri)
+    : m_uri(std::move(_uri))
     , m_cursor_pos(s_noPosition)
     , m_selection_bound_pos(s_noPosition)
     , m_width(0)
diff --git a/src/notebase.cpp b/src/notebase.cpp
index 24fba50e..c5b75cdd 100644
--- a/src/notebase.cpp
+++ b/src/notebase.cpp
@@ -113,9 +113,9 @@ Glib::ustring NoteBase::parse_text_content(const Glib::ustring & content)
 }
 
 
-NoteBase::NoteBase(const Glib::ustring & filepath, NoteManagerBase & _manager)
+NoteBase::NoteBase(const Glib::ustring && filepath, NoteManagerBase & _manager)
   : m_manager(_manager)
-  , m_file_path(filepath)
+  , m_file_path(std::move(filepath))
   , m_enabled(true)
 {
 }
diff --git a/src/notebase.hpp b/src/notebase.hpp
index d37015dd..93048eae 100644
--- a/src/notebase.hpp
+++ b/src/notebase.hpp
@@ -46,7 +46,7 @@ public:
 
   static const int s_noPosition;
 
-  NoteData(const Glib::ustring & _uri);
+  NoteData(Glib::ustring && _uri);
 
   const Glib::ustring & uri() const
     {
@@ -195,7 +195,7 @@ public:
   static std::vector<Glib::ustring> parse_tags(const xmlNodePtr tagnodes);
   static Glib::ustring parse_text_content(const Glib::ustring & content);
 
-  NoteBase(const Glib::ustring & filepath, NoteManagerBase & manager);
+  NoteBase(const Glib::ustring && filepath, NoteManagerBase & manager);
   virtual ~NoteBase() {}
 
   NoteManagerBase & manager()
diff --git a/src/notemanager.cpp b/src/notemanager.cpp
index 0cad04f4..4606f515 100644
--- a/src/notemanager.cpp
+++ b/src/notemanager.cpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2010-2014,2017,2019-2021 Aurimas Cernius
+ * Copyright (C) 2010-2014,2017,2019-2022 Aurimas Cernius
  * Copyright (C) 2010 Debarshi Ray
  * Copyright (C) 2009 Hubert Figuiere
  *
@@ -278,9 +278,9 @@ namespace gnote {
     return new_note;
   }
 
-  NoteBase::Ptr NoteManager::note_create_new(const Glib::ustring & title, const Glib::ustring & file_name)
+  NoteBase::Ptr NoteManager::note_create_new(Glib::ustring && title, Glib::ustring && file_name)
   {
-    return Note::create_new_note(Glib::ustring(title), Glib::ustring(file_name), *this, m_gnote);
+    return Note::create_new_note(std::move(title), std::move(file_name), *this, m_gnote);
   }
 
   NoteBase::Ptr NoteManager::get_or_create_template_note()
diff --git a/src/notemanager.hpp b/src/notemanager.hpp
index fc3cd731..21b992e3 100644
--- a/src/notemanager.hpp
+++ b/src/notemanager.hpp
@@ -80,7 +80,7 @@ namespace gnote {
     virtual NoteBase::Ptr create_note(Glib::ustring title, Glib::ustring body, const Glib::ustring & guid = 
Glib::ustring()) override;
     virtual NoteBase::Ptr create_new_note(const Glib::ustring & title, const Glib::ustring & xml_content,
                                           const Glib::ustring & guid) override;
-    virtual NoteBase::Ptr note_create_new(const Glib::ustring & title, const Glib::ustring & file_name) 
override;
+    virtual NoteBase::Ptr note_create_new(Glib::ustring && title, Glib::ustring && file_name) override;
     NoteBase::Ptr note_load(Glib::ustring && file_name) override;
   private:
     AddinManager *create_addin_manager();
diff --git a/src/notemanagerbase.cpp b/src/notemanagerbase.cpp
index 1927679c..720ac389 100644
--- a/src/notemanagerbase.cpp
+++ b/src/notemanagerbase.cpp
@@ -330,7 +330,7 @@ NoteBase::Ptr NoteManagerBase::create_new_note(const Glib::ustring & title, cons
   else
     filename = make_new_file_name();
 
-  NoteBase::Ptr new_note = note_create_new(title, filename);
+  NoteBase::Ptr new_note = note_create_new(Glib::ustring(title), Glib::ustring(filename));
   if(new_note == 0) {
     throw sharp::Exception("Failed to create new note");
   }
diff --git a/src/notemanagerbase.hpp b/src/notemanagerbase.hpp
index b7a9875b..0ba5fc01 100644
--- a/src/notemanagerbase.hpp
+++ b/src/notemanagerbase.hpp
@@ -110,7 +110,7 @@ protected:
   virtual NoteBase::Ptr create_note(Glib::ustring title, Glib::ustring body, const Glib::ustring & guid = 
Glib::ustring());
   virtual NoteBase::Ptr create_new_note(const Glib::ustring & title, const Glib::ustring & xml_content, 
                                         const Glib::ustring & guid);
-  virtual NoteBase::Ptr note_create_new(const Glib::ustring & title, const Glib::ustring & file_name) = 0;
+  virtual NoteBase::Ptr note_create_new(Glib::ustring && title, Glib::ustring && file_name) = 0;
   Glib::ustring make_new_file_name() const;
   Glib::ustring make_new_file_name(const Glib::ustring & guid) const;
   virtual NoteBase::Ptr note_load(Glib::ustring && file_name) = 0;
diff --git a/src/synchronization/syncutils.cpp b/src/synchronization/syncutils.cpp
index 91966830..1bdf364f 100644
--- a/src/synchronization/syncutils.cpp
+++ b/src/synchronization/syncutils.cpp
@@ -55,7 +55,7 @@ namespace sync {
     //       was not just a container for a big XML string
     sharp::XmlReader xml;
     xml.load_buffer(m_xml_content);
-    NoteData *data = new NoteData(m_uuid);
+    NoteData *data = new NoteData(Glib::ustring(m_uuid));
     existing_note->manager().note_archiver().read(xml, *data);
     std::unique_ptr<NoteData> update_data(data);
     xml.close();
diff --git a/src/test/testnote.cpp b/src/test/testnote.cpp
index ce92328c..6b1729b1 100644
--- a/src/test/testnote.cpp
+++ b/src/test/testnote.cpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2014,2018-2019 Aurimas Cernius
+ * Copyright (C) 2014,2018-2019,2022 Aurimas Cernius
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -22,8 +22,8 @@
 
 namespace test {
 
-Note::Note(std::unique_ptr<gnote::NoteData> _data, const Glib::ustring & filepath, gnote::NoteManagerBase & 
manager_)
-  : gnote::NoteBase(filepath, manager_)
+Note::Note(std::unique_ptr<gnote::NoteData> _data, Glib::ustring && filepath, gnote::NoteManagerBase & 
manager_)
+  : gnote::NoteBase(std::move(filepath), manager_)
   , m_data_synchronizer(std::move(_data))
 {
 }
diff --git a/src/test/testnote.hpp b/src/test/testnote.hpp
index e3db09b4..b538a752 100644
--- a/src/test/testnote.hpp
+++ b/src/test/testnote.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2014,2018-2019 Aurimas Cernius
+ * Copyright (C) 2014,2018-2019,2022 Aurimas Cernius
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@ class Note
   : public gnote::NoteBase
 {
 public:
-  Note(std::unique_ptr<gnote::NoteData> _data, const Glib::ustring & filepath, gnote::NoteManagerBase & 
manager);
+  Note(std::unique_ptr<gnote::NoteData> _data, Glib::ustring && filepath, gnote::NoteManagerBase & manager);
   void set_change_type(gnote::ChangeType c);
 protected:
   virtual const gnote::NoteDataBufferSynchronizerBase & data_synchronizer() const;
diff --git a/src/test/testnotemanager.cpp b/src/test/testnotemanager.cpp
index be03dac3..97fc5be8 100644
--- a/src/test/testnotemanager.cpp
+++ b/src/test/testnotemanager.cpp
@@ -49,15 +49,15 @@ NoteManager::~NoteManager()
   remove_dir(notes_dir());
 }
 
-gnote::NoteBase::Ptr NoteManager::note_create_new(const Glib::ustring & title, const Glib::ustring & 
file_name)
+gnote::NoteBase::Ptr NoteManager::note_create_new(Glib::ustring && title, Glib::ustring && file_name)
 {
   auto note_data = std::make_unique<gnote::NoteData>(gnote::NoteBase::url_from_path(file_name));
-  note_data->title() = title;
+  note_data->title() = std::move(title);
   Glib::DateTime date(Glib::DateTime::create_now_local());
   note_data->create_date() = date;
   note_data->set_change_date(date);
 
-  return std::make_shared<Note>(std::move(note_data), file_name, *this);
+  return std::make_shared<Note>(std::move(note_data), std::move(file_name), *this);
 }
 
 gnote::NoteBase::Ptr NoteManager::note_load(Glib::ustring && /*file_name*/)
diff --git a/src/test/testnotemanager.hpp b/src/test/testnotemanager.hpp
index d05374d0..f62d7d18 100644
--- a/src/test/testnotemanager.hpp
+++ b/src/test/testnotemanager.hpp
@@ -51,7 +51,7 @@ public:
       return m_tag_manager;
     }
 protected:
-  virtual gnote::NoteBase::Ptr note_create_new(const Glib::ustring & title, const Glib::ustring & file_name) 
override;
+  virtual gnote::NoteBase::Ptr note_create_new(Glib::ustring && title, Glib::ustring && file_name) override;
   gnote::NoteBase::Ptr note_load(Glib::ustring && file_name) override;
 private:
   gnote::notebooks::NotebookManager m_notebook_manager;


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