[gnote] Replace std::list with std::vector in tagmanager
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Replace std::list with std::vector in tagmanager
- Date: Sun, 28 Apr 2019 16:30:26 +0000 (UTC)
commit 277fd83b5c4ba666982f83b7b9d14f9388d26d1c
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sun Apr 28 19:18:08 2019 +0300
Replace std::list with std::vector in tagmanager
src/itagmanager.hpp | 4 +---
src/notebooks/notebookmanager.cpp | 8 ++------
src/tagmanager.cpp | 11 +++++++----
src/tagmanager.hpp | 2 +-
src/test/testtagmanager.cpp | 6 +++---
src/test/testtagmanager.hpp | 2 +-
6 files changed, 15 insertions(+), 18 deletions(-)
---
diff --git a/src/itagmanager.hpp b/src/itagmanager.hpp
index 51beac00..607b3e0d 100644
--- a/src/itagmanager.hpp
+++ b/src/itagmanager.hpp
@@ -20,8 +20,6 @@
#ifndef _ITAGMANAGER_HPP_
#define _ITAGMANAGER_HPP_
-#include <list>
-
#include <glibmm/ustring.h>
#include "tag.hpp"
@@ -45,7 +43,7 @@ public:
virtual Tag::Ptr get_system_tag(const Glib::ustring & tag_name) const = 0;
virtual Tag::Ptr get_or_create_system_tag(const Glib::ustring & name) = 0;
virtual void remove_tag(const Tag::Ptr & tag) = 0;
- virtual void all_tags(std::list<Tag::Ptr> &) const = 0;
+ virtual std::vector<Tag::Ptr> all_tags() const = 0;
};
}
diff --git a/src/notebooks/notebookmanager.cpp b/src/notebooks/notebookmanager.cpp
index 02bfc735..594fd792 100644
--- a/src/notebooks/notebookmanager.cpp
+++ b/src/notebooks/notebookmanager.cpp
@@ -463,12 +463,8 @@ namespace gnote {
void NotebookManager::load_notebooks()
{
Gtk::TreeIter iter;
- std::list<Tag::Ptr> tags;
- ITagManager::obj().all_tags(tags);
- for(std::list<Tag::Ptr>::const_iterator tag_iter = tags.begin();
- tag_iter != tags.end(); ++tag_iter) {
-
- const Tag::Ptr & tag(*tag_iter);
+ auto tags = ITagManager::obj().all_tags();
+ for(const auto & tag : tags) {
// Skip over tags that aren't notebooks
if (!tag->is_system()
|| !Glib::str_has_prefix(tag->name(),
diff --git a/src/tagmanager.cpp b/src/tagmanager.cpp
index bdeb4c55..8b712d28 100644
--- a/src/tagmanager.cpp
+++ b/src/tagmanager.cpp
@@ -220,12 +220,13 @@ namespace gnote {
}
}
- void TagManager::all_tags(std::list<Tag::Ptr> & tags) const
+ std::vector<Tag::Ptr> TagManager::all_tags() const
{
+ std::vector<Tag::Ptr> tags;
+
// Add in the system tags first
- std::vector<Tag::Ptr> tmp = sharp::map_get_values(m_internal_tags);
- tags.insert(tags.end(), tmp.begin(), tmp.end());
-
+ tags = sharp::map_get_values(m_internal_tags);
+
// Now all the other tags
for(TagMap::const_iterator iter = m_tag_map.begin();
iter != m_tag_map.end(); ++iter) {
@@ -233,6 +234,8 @@ namespace gnote {
iter->second->get_value(0, tag);
tags.push_back(tag);
}
+
+ return tags;
}
}
diff --git a/src/tagmanager.hpp b/src/tagmanager.hpp
index dc2fc6f9..9b3dac03 100644
--- a/src/tagmanager.hpp
+++ b/src/tagmanager.hpp
@@ -52,7 +52,7 @@ public:
{
return m_sorted_tags;
}
- virtual void all_tags(std::list<Tag::Ptr> &) const override;
+ virtual std::vector<Tag::Ptr> all_tags() const override;
private:
class ColumnRecord
: public Gtk::TreeModelColumnRecord
diff --git a/src/test/testtagmanager.cpp b/src/test/testtagmanager.cpp
index cef85c45..d1715cb9 100644
--- a/src/test/testtagmanager.cpp
+++ b/src/test/testtagmanager.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2014,2017-2018 Aurimas Cernius
+ * Copyright (C) 2014,2017-2019 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
@@ -73,9 +73,9 @@ void TagManager::remove_tag(const gnote::Tag::Ptr & tag)
}
}
-void TagManager::all_tags(std::list<gnote::Tag::Ptr> & list) const
+std::vector<gnote::Tag::Ptr> TagManager::all_tags() const
{
- list.clear();
+ std::vector<gnote::Tag::Ptr> list;
for(auto iter = m_tags.begin(); iter != m_tags.end(); ++iter) {
list.push_back(iter->second);
}
diff --git a/src/test/testtagmanager.hpp b/src/test/testtagmanager.hpp
index 2288a3cc..259d8f88 100644
--- a/src/test/testtagmanager.hpp
+++ b/src/test/testtagmanager.hpp
@@ -33,7 +33,7 @@ public:
virtual gnote::Tag::Ptr get_system_tag(const Glib::ustring & tag_name) const override;
virtual gnote::Tag::Ptr get_or_create_system_tag(const Glib::ustring & name) override;
virtual void remove_tag(const gnote::Tag::Ptr & tag) override;
- virtual void all_tags(std::list<gnote::Tag::Ptr> &) const override;
+ virtual std::vector<gnote::Tag::Ptr> all_tags() const override;
private:
static TagManager* s_manager;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]