From c386cd88eca1a7523226dc78fce9d134f4915099 Mon Sep 17 00:00:00 2001 From: John Levon Date: Sun, 9 Feb 2003 00:27:52 +0000 Subject: [PATCH] replace hand-coded list walk with a std::map for dep clean git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6078 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 5 +++++ src/buffer.C | 42 +++++++++++++----------------------------- src/buffer.h | 18 +++++------------- 3 files changed, 23 insertions(+), 42 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index c07b42f6e6..711b061e1f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2003-02-09 John Levon + + * buffer.h: + * buffer.C: replace hand-coded list with a map for the dep clean + 2003-02-08 John Levon * LaTeX.C: consolidate code into showRunMessage() helper diff --git a/src/buffer.C b/src/buffer.C index 60ec905f47..6a3c50a5d6 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -156,7 +156,7 @@ const int LYX_FORMAT = 222; Buffer::Buffer(string const & file, bool ronly) : niceFile(true), lyx_clean(true), bak_clean(true), - unnamed(false), dep_clean(0), read_only(ronly), + unnamed(false), read_only(ronly), filename_(file), users(0) { lyxerr[Debug::INFO] << "Buffer::Buffer()" << endl; @@ -305,7 +305,7 @@ vector author_ids; // changed to be public and have one parameter // if par = 0 normal behavior // else insert behavior -// Returns false if "\the_end" is not read for formats >= 2.13. (Asger) +// Returns false if "\the_end" is not read (Asger) bool Buffer::readLyXformat2(LyXLex & lex, Paragraph * par) { unknown_layouts = 0; @@ -3302,34 +3302,16 @@ vector > const Buffer::getBibkeyList() const bool Buffer::isDepClean(string const & name) const { - DEPCLEAN * item = dep_clean; - while (item && item->master != name) - item = item->next; - if (!item) return true; - return item->clean; + DepClean::const_iterator it = dep_clean_.find(name); + if (it == dep_clean_.end()) + return true; + return it->second; } void Buffer::markDepClean(string const & name) { - if (!dep_clean) { - dep_clean = new DEPCLEAN; - dep_clean->clean = true; - dep_clean->master = name; - dep_clean->next = 0; - } else { - DEPCLEAN * item = dep_clean; - while (item && item->master != name) - item = item->next; - if (item) { - item->clean = true; - } else { - item = new DEPCLEAN; - item->clean = true; - item->master = name; - item->next = 0; - } - } + dep_clean_[name] = true; } @@ -3536,10 +3518,12 @@ void Buffer::markDirty() updateTitles(); } bak_clean = false; - DEPCLEAN * tmp = dep_clean; - while (tmp) { - tmp->clean = false; - tmp = tmp->next; + + DepClean::iterator it = dep_clean_.begin(); + DepClean::const_iterator const end = dep_clean_.end(); + + for (; it != end; ++it) { + it->second = false; } } diff --git a/src/buffer.h b/src/buffer.h index e3fc7d69a6..acde4e5af0 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -39,16 +39,6 @@ class ParIterator; class ParConstIterator; -/// -struct DEPCLEAN { - /// - bool clean; - /// - string master; - /// - DEPCLEAN * next; -}; - /** The buffer object. This is the buffer object. It contains all the informations about a document loaded into LyX. I am not sure if the class is complete or @@ -308,6 +298,11 @@ public: AuthorList & authors(); private: + typedef std::map DepClean; + + /// need to regenerate .tex ? + DepClean dep_clean_; + /// the author list AuthorList authorlist; @@ -320,9 +315,6 @@ private: /// is this a unnamed file (New...) bool unnamed; - /// is regenerating #.tex# necessary - DEPCLEAN * dep_clean; - /// buffer is r/o bool read_only;