[gnote] Replace std::list with std::vector in notebuffer
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Replace std::list with std::vector in notebuffer
- Date: Sun, 21 Apr 2019 18:04:12 +0000 (UTC)
commit 282c3a9a895258055946b28677595b29248bb6ad
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sun Apr 21 20:45:18 2019 +0300
Replace std::list with std::vector in notebuffer
src/notebuffer.cpp | 18 ++++--------------
src/notebuffer.hpp | 2 +-
2 files changed, 5 insertions(+), 15 deletions(-)
---
diff --git a/src/notebuffer.cpp b/src/notebuffer.cpp
index 9098e4db..cb33493d 100644
--- a/src/notebuffer.cpp
+++ b/src/notebuffer.cpp
@@ -102,12 +102,7 @@ namespace gnote {
}
}
else {
- std::list<Glib::RefPtr<Gtk::TextTag> >::iterator iter = std::find(m_active_tags.begin(),
- m_active_tags.end(), tag);
- if (iter != m_active_tags.end()) {
- m_active_tags.erase(iter);
- }
- else {
+ if(!utils::remove_swap_back(m_active_tags, tag)) {
m_active_tags.push_back(tag);
}
}
@@ -139,11 +134,7 @@ namespace gnote {
remove_tag(tag, select_start, select_end);
}
else {
- std::list<Glib::RefPtr<Gtk::TextTag> >::iterator iter = std::find(m_active_tags.begin(),
- m_active_tags.end(), tag);
- if (iter != m_active_tags.end()) {
- m_active_tags.erase(iter);
- }
+ utils::remove_swap_back(m_active_tags, tag);
}
}
@@ -293,9 +284,8 @@ namespace gnote {
remove_tag(*tag_iter, insert_start, pos);
}
- for(std::list<Glib::RefPtr<Gtk::TextTag> >::const_iterator iter = m_active_tags.begin();
- iter != m_active_tags.end(); ++iter) {
- apply_tag(*iter, insert_start, pos);
+ for(auto & tag : m_active_tags) {
+ apply_tag(tag, insert_start, pos);
}
m_undomanager->thaw_undo();
}
diff --git a/src/notebuffer.hpp b/src/notebuffer.hpp
index e8409a38..71e5558f 100644
--- a/src/notebuffer.hpp
+++ b/src/notebuffer.hpp
@@ -153,7 +153,7 @@ private:
// HATE.
// list of Glib::RefPtr<Gtk::TextTag>s to apply on insert
- std::list<Glib::RefPtr<Gtk::TextTag> > m_active_tags;
+ std::vector<Glib::RefPtr<Gtk::TextTag> > m_active_tags;
// The note that owns this buffer
Note & m_note;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]