[gnote] Replace std::list with std::vector in undo
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Replace std::list with std::vector in undo
- Date: Sun, 28 Apr 2019 16:30:21 +0000 (UTC)
commit 531cf5606592e3aa93b5e825a88c970ca807e8e2
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sun Apr 28 18:00:40 2019 +0300
Replace std::list with std::vector in undo
src/undo.cpp | 15 +++++----------
src/undo.hpp | 5 ++---
2 files changed, 7 insertions(+), 13 deletions(-)
---
diff --git a/src/undo.cpp b/src/undo.cpp
index b1f11ea1..57709dc3 100644
--- a/src/undo.cpp
+++ b/src/undo.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2010,2016-2017 Aurimas Cernius
+ * Copyright (C) 2010,2016-2017,2019 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -125,9 +125,8 @@ namespace gnote {
int SplitterAction::get_split_offset() const
{
int offset = 0;
- for(std::list<TagData>::const_iterator iter = m_splitTags.begin();
- iter != m_splitTags.end(); ++iter) {
- NoteTag::Ptr noteTag = NoteTag::Ptr::cast_dynamic(iter->tag);
+ for(auto & iter : m_splitTags) {
+ NoteTag::Ptr noteTag = NoteTag::Ptr::cast_dynamic(iter.tag);
if (noteTag->get_image()) {
offset++;
}
@@ -138,9 +137,7 @@ namespace gnote {
void SplitterAction::apply_split_tag(Gtk::TextBuffer * buffer)
{
- for(std::list<TagData>::const_iterator iter = m_splitTags.begin();
- iter != m_splitTags.end(); ++iter) {
- const TagData & tag(*iter);
+ for(const auto & tag : m_splitTags) {
int offset = get_split_offset ();
Gtk::TextIter start = buffer->get_iter_at_offset (tag.start - offset);
@@ -152,9 +149,7 @@ namespace gnote {
void SplitterAction::remove_split_tags(Gtk::TextBuffer *buffer)
{
- for(std::list<TagData>::const_iterator iter = m_splitTags.begin();
- iter != m_splitTags.end(); ++iter) {
- const TagData & tag(*iter);
+ for(const auto & tag : m_splitTags) {
Gtk::TextIter start = buffer->get_iter_at_offset (tag.start);
Gtk::TextIter end = buffer->get_iter_at_offset (tag.end);
buffer->remove_tag(tag.tag, start, end);
diff --git a/src/undo.hpp b/src/undo.hpp
index 3a8543e0..00c29206 100644
--- a/src/undo.hpp
+++ b/src/undo.hpp
@@ -23,7 +23,6 @@
#ifndef __UNDO_HPP_
#define __UNDO_HPP_
-#include <list>
#include <stack>
#include <sigc++/signal.h>
@@ -91,7 +90,7 @@ public:
{
return m_chop;
}
- const std::list<TagData> & get_split_tags() const
+ const std::vector<TagData> & get_split_tags() const
{
return m_splitTags;
}
@@ -103,7 +102,7 @@ protected:
int get_split_offset() const;
void apply_split_tag(Gtk::TextBuffer *);
void remove_split_tags(Gtk::TextBuffer *);
- std::list<TagData> m_splitTags;
+ std::vector<TagData> m_splitTags;
utils::TextRange m_chop;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]