commit 9c37cb47594a5a6d57b77a313b5ddce03cf01aa1
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Wed Jan 6 14:18:25 2021 +0100

    Style cleanup to bookmark code
---
 src/Session.cpp |    8 ++++----
 src/Session.h   |   10 +++++-----
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/Session.cpp b/src/Session.cpp
index c80bca5..cfb2565 100644
--- a/src/Session.cpp
+++ b/src/Session.cpp
@@ -283,7 +283,7 @@ void BookmarksSection::read(istream & is)
                                continue;
                        FileName const file(fname);
                        // only load valid bookmarks
-                       if (file.exists() && !file.isDirectory() && idx <= 
max_bookmarks)
+                       if (file.exists() && !file.isDirectory() && idx < 
bookmarks.size())
                                bookmarks[idx] = Bookmark(file, pit, pos, 0, 0);
                        else
                                LYXERR(Debug::INIT, "LyX: Warning: Ignore 
bookmark of file: " << fname);
@@ -297,7 +297,7 @@ void BookmarksSection::read(istream & is)
 void BookmarksSection::write(ostream & os) const
 {
        os << '\n' << sec_bookmarks << '\n';
-       for (size_t i = 0; i <= max_bookmarks; ++i) {
+       for (size_t i = 0; i < bookmarks.size(); ++i) {
                if (isValid(i))
                        os << i << ", "
                           << bookmarks[i].bottom_pit << ", "
@@ -312,14 +312,14 @@ void BookmarksSection::save(FileName const & fname,
        int top_id, pos_type top_pos, unsigned int idx)
 {
        // silently ignore bookmarks when idx is out of range
-       if (idx <= max_bookmarks)
+       if (idx < bookmarks.size())
                bookmarks[idx] = Bookmark(fname, bottom_pit, bottom_pos, 
top_id, top_pos);
 }
 
 
 bool BookmarksSection::isValid(unsigned int i) const
 {
-       return i <= max_bookmarks && !bookmarks[i].filename.empty();
+       return i < bookmarks.size() && !bookmarks[i].filename.empty();
 }
 
 
diff --git a/src/Session.h b/src/Session.h
index 5af5554..9cbe6d8 100644
--- a/src/Session.h
+++ b/src/Session.h
@@ -229,9 +229,8 @@ public:
        typedef std::vector<Bookmark> BookmarkList;
 
 public:
-       /// constructor, set max_bookmarks
-       /// allow 9 regular bookmarks, bookmark 0 is temporary
-       BookmarksSection() : bookmarks(10), max_bookmarks(9) {}
+       ///
+       BookmarksSection() : bookmarks(max_bookmarks + 1) {}
 
        /// Save the current position as bookmark
        void save(support::FileName const & fname, pit_type bottom_pit, 
pos_type bottom_pos,
@@ -265,11 +264,12 @@ public:
 
 private:
 
+       /// allow 9 regular bookmarks, bookmark 0 is temporary
+       unsigned int const max_bookmarks = 9;
+
        /// a list of bookmarks
        BookmarkList bookmarks;
 
-       ///
-       unsigned int const max_bookmarks;
 };
 
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to