]> git.lyx.org Git - features.git/commitdiff
replace hand-coded list walk with a std::map for dep clean
authorJohn Levon <levon@movementarian.org>
Sun, 9 Feb 2003 00:27:52 +0000 (00:27 +0000)
committerJohn Levon <levon@movementarian.org>
Sun, 9 Feb 2003 00:27:52 +0000 (00:27 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6078 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/buffer.C
src/buffer.h

index c07b42f6e6021403ccae7cff7a7bad2a067dd3b6..711b061e1f6576539ca789c43b0bdf42457619db 100644 (file)
@@ -1,3 +1,8 @@
+2003-02-09  John Levon  <levon@movementarian.org>
+
+       * buffer.h:
+       * buffer.C: replace hand-coded list with a map for the dep clean
+
 2003-02-08  John Levon  <levon@movementarian.org>
 
        * LaTeX.C: consolidate code into showRunMessage() helper
index 60ec905f4766c894bbe4ac7b72238c25a9215f37..6a3c50a5d69ad9b8e3c3961b04405fe98a8279ba 100644 (file)
@@ -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<int> 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<pair<string, string> > 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;
        }
 }
 
index e3fc7d69a6aaf80cb00b84badc41ed56dfdc37f4..acde4e5af0ca54df877ccfa5ca4ea8c07f9bb43a 100644 (file)
@@ -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<string, bool> 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;