[gnote] Replace std::list with std::vector for NoteBase::List



commit 779deb2e37ac037710991ebf755d921420188f96
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sun Apr 28 17:41:40 2019 +0300

    Replace std::list with std::vector for NoteBase::List

 src/notebase.hpp                    |  2 +-
 src/notemanagerbase.cpp             | 13 +++++++++----
 src/synchronization/syncmanager.cpp |  2 +-
 3 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/src/notebase.hpp b/src/notebase.hpp
index d80b0134..398f16e0 100644
--- a/src/notebase.hpp
+++ b/src/notebase.hpp
@@ -190,7 +190,7 @@ class NoteBase
 public:
   typedef std::shared_ptr<NoteBase> Ptr;
   typedef std::weak_ptr<NoteBase> WeakPtr;
-  typedef std::list<Ptr> List;
+  typedef std::vector<Ptr> List;
 
   static Glib::ustring url_from_path(const Glib::ustring &);
   static std::vector<Glib::ustring> parse_tags(const xmlNodePtr tagnodes);
diff --git a/src/notemanagerbase.cpp b/src/notemanagerbase.cpp
index 88b67cf8..c38b5d43 100644
--- a/src/notemanagerbase.cpp
+++ b/src/notemanagerbase.cpp
@@ -159,7 +159,7 @@ TrieController *NoteManagerBase::create_trie_controller()
 
 void NoteManagerBase::post_load()
 {
-  m_notes.sort(compare_dates);
+  std::sort(m_notes.begin(), m_notes.end(), compare_dates);
 
   // Update the trie so addins can access it, if they want.
   m_trie_controller->update ();
@@ -201,13 +201,13 @@ void NoteManagerBase::add_note(const NoteBase::Ptr & note)
 void NoteManagerBase::on_note_rename(const NoteBase::Ptr & note, const Glib::ustring & old_title)
 {
   signal_note_renamed(note, old_title);
-  m_notes.sort(compare_dates);
+  std::sort(m_notes.begin(), m_notes.end(), compare_dates);
 }
 
 void NoteManagerBase::on_note_save (const NoteBase::Ptr & note)
 {
   signal_note_saved(note);
-  m_notes.sort(compare_dates);
+  std::sort(m_notes.begin(), m_notes.end(), compare_dates);
 }
 
 NoteBase::Ptr NoteManagerBase::find(const Glib::ustring & linked_title) const
@@ -465,7 +465,12 @@ void NoteManagerBase::delete_note(const NoteBase::Ptr & note)
     }
   }
 
-  m_notes.remove(note);
+  for(auto iter = m_notes.begin(); iter != m_notes.end(); ++iter) {
+    if(*iter == note) {
+      m_notes.erase(iter);
+      break;
+    }
+  }
   note->delete_note();
 
   DBG_OUT("Deleting note '%s'.", note->get_title().c_str());
diff --git a/src/synchronization/syncmanager.cpp b/src/synchronization/syncmanager.cpp
index 55c201ec..74d808f8 100644
--- a/src/synchronization/syncmanager.cpp
+++ b/src/synchronization/syncmanager.cpp
@@ -686,7 +686,7 @@ namespace sync {
   {
     try {
       // Make list of all local notes
-      std::list<NoteBase::Ptr> localNotes = note_mgr().get_notes();
+      auto localNotes = note_mgr().get_notes();
 
       // Get all notes currently on server
       auto serverNotes = server->get_all_note_uuids();


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