[gnote] Replace std::list with std::vector in tag
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Replace std::list with std::vector in tag
- Date: Sun, 21 Apr 2019 18:04:22 +0000 (UTC)
commit 789577175a8a735c43b5d188f8fce326a1ed69e5
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sun Apr 21 21:03:38 2019 +0300
Replace std::list with std::vector in tag
src/dbus/remotecontrol.cpp | 3 +--
src/notebooks/notebook.cpp | 6 ++----
src/notebooks/notebookmanager.cpp | 4 ++--
src/notemanagerbase.cpp | 3 +--
src/searchnoteswidget.cpp | 3 +--
src/tag.cpp | 5 ++---
src/tag.hpp | 4 ++--
src/tagmanager.cpp | 3 +--
8 files changed, 12 insertions(+), 19 deletions(-)
---
diff --git a/src/dbus/remotecontrol.cpp b/src/dbus/remotecontrol.cpp
index 6f836b63..0db52ceb 100644
--- a/src/dbus/remotecontrol.cpp
+++ b/src/dbus/remotecontrol.cpp
@@ -171,8 +171,7 @@ namespace gnote {
return std::vector<Glib::ustring>();
std::vector<Glib::ustring> tagged_note_uris;
- std::list<NoteBase*> notes;
- tag->get_notes(notes);
+ auto notes = tag->get_notes();
for(NoteBase *iter : notes) {
tagged_note_uris.push_back(iter->uri());
}
diff --git a/src/notebooks/notebook.cpp b/src/notebooks/notebook.cpp
index 8d465183..9dd20a32 100644
--- a/src/notebooks/notebook.cpp
+++ b/src/notebooks/notebook.cpp
@@ -131,8 +131,7 @@ namespace notebooks {
if(!templ_tag || !notebook_tag) {
return note;
}
- std::list<NoteBase*> notes;
- templ_tag->get_notes(notes);
+ auto notes = templ_tag->get_notes();
for(NoteBase *n : notes) {
if(n->contains_tag(notebook_tag)) {
note = std::static_pointer_cast<Note>(n->shared_from_this());
@@ -150,8 +149,7 @@ namespace notebooks {
if (!note) {
Glib::ustring title = m_default_template_note_title;
if(m_note_manager.find(title)) {
- std::list<NoteBase*> tag_notes;
- m_tag->get_notes(tag_notes);
+ auto tag_notes = m_tag->get_notes();
title = m_note_manager.get_unique_name(title);
}
note = m_note_manager.create(title, NoteManager::get_note_template_content (title));
diff --git a/src/notebooks/notebookmanager.cpp b/src/notebooks/notebookmanager.cpp
index 925ee6ca..02bfc735 100644
--- a/src/notebooks/notebookmanager.cpp
+++ b/src/notebooks/notebookmanager.cpp
@@ -189,10 +189,10 @@ namespace gnote {
m_notebooks->erase (iter);
// Remove the notebook tag from every note that's in the notebook
- std::list<NoteBase*> notes;
+ std::vector<NoteBase*> notes;
Tag::Ptr tag = notebook->get_tag();
if(tag) {
- tag->get_notes(notes);
+ notes = tag->get_notes();
}
for(NoteBase *note : notes) {
note->remove_tag (notebook->get_tag());
diff --git a/src/notemanagerbase.cpp b/src/notemanagerbase.cpp
index f6b79ced..88b67cf8 100644
--- a/src/notemanagerbase.cpp
+++ b/src/notemanagerbase.cpp
@@ -432,8 +432,7 @@ NoteBase::Ptr NoteManagerBase::find_template_note() const
if(!template_tag) {
return template_note;
}
- std::list<NoteBase*> notes;
- template_tag->get_notes(notes);
+ auto notes = template_tag->get_notes();
for(NoteBase *iter : notes) {
NoteBase::Ptr note = iter->shared_from_this();
if(!notebooks::NotebookManager::obj().get_notebook_from_note(note)) {
diff --git a/src/searchnoteswidget.cpp b/src/searchnoteswidget.cpp
index 23853945..e83c0984 100644
--- a/src/searchnoteswidget.cpp
+++ b/src/searchnoteswidget.cpp
@@ -343,8 +343,7 @@ void SearchNotesWidget::on_notebook_row_edited(const Glib::ustring& /*tree_path*
.get_or_create_notebook(new_text);
DBG_OUT("Renaming notebook '{%s}' to '{%s}'", old_notebook->get_name().c_str(),
new_text.c_str());
- std::list<NoteBase*> notes;
- old_notebook->get_tag()->get_notes(notes);
+ auto notes = old_notebook->get_tag()->get_notes();
for(NoteBase *note : notes) {
notebooks::NotebookManager::obj().move_note_to_notebook(
std::static_pointer_cast<Note>(note->shared_from_this()), new_notebook);
diff --git a/src/tag.cpp b/src/tag.cpp
index bfae9227..83693b5d 100644
--- a/src/tag.cpp
+++ b/src/tag.cpp
@@ -76,10 +76,9 @@ namespace gnote {
}
- void Tag::get_notes(std::list<NoteBase*> & l) const
+ std::vector<NoteBase*> Tag::get_notes() const
{
- std::vector<NoteBase*> notes = sharp::map_get_values(m_notes);
- l.insert(l.end(), notes.begin(), notes.end());
+ return sharp::map_get_values(m_notes);
}
diff --git a/src/tag.hpp b/src/tag.hpp
index 90156a3c..d204d21f 100644
--- a/src/tag.hpp
+++ b/src/tag.hpp
@@ -24,9 +24,9 @@
#ifndef __TAG_HPP_
#define __TAG_HPP_
-#include <list>
#include <map>
#include <memory>
+#include <vector>
#include <glibmm/ustring.h>
@@ -91,7 +91,7 @@ namespace gnote {
// Returns a list of all the notes that this tag is associated with.
// These pointer are not meant to be freed. They are OWNED.
// </summary>
- void get_notes(std::list<NoteBase*> &) const;
+ std::vector<NoteBase*> get_notes() const;
// <summary>
// Returns the number of notes this is currently tagging.
// </summary>
diff --git a/src/tagmanager.cpp b/src/tagmanager.cpp
index e27771c4..bdeb4c55 100644
--- a/src/tagmanager.cpp
+++ b/src/tagmanager.cpp
@@ -208,8 +208,7 @@ namespace gnote {
DBG_OUT("Removed TreeIter from tag_map: %s", tag->normalized_name().c_str());
tag_removed = true;
- std::list<NoteBase*> notes;
- tag->get_notes(notes);
+ auto notes = tag->get_notes();
for(NoteBase *note_iter : notes) {
note_iter->remove_tag(tag);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]