Edwin,

could you please check whether the attached patch saves any time in lyx::Changes::lookup(int) const and lyx::Changes::merge() during opening/saving a file?

Michael
Index: changes.C
===================================================================
--- changes.C   (Revision 16573)
+++ changes.C   (Arbeitskopie)
@@ -77,18 +77,6 @@
 }
 
 
-bool Changes::Range::contains(Range const & r) const
-{
-       return r.start >= start && r.end <= end;
-}
-
-
-bool Changes::Range::contains(pos_type const pos) const
-{
-       return pos >= start && pos < end;
-}
-
-
 bool Changes::Range::intersects(Range const & r) const
 {
        return r.start < end && r.end > start; // end itself is not in the 
range!
@@ -230,8 +218,10 @@
 }
 
 
-Change const Changes::lookup(pos_type const pos) const
+Change const & Changes::lookup(pos_type const pos) const
 {
+       static Change const noChange = Change(Change::UNCHANGED);
+               
        ChangeTable::const_iterator it = table_.begin();
        ChangeTable::const_iterator const end = table_.end();
 
@@ -240,7 +230,7 @@
                        return it->change;
        }
 
-       return Change(Change::UNCHANGED);
+       return noChange;
 }
 
 
Index: changes.h
===================================================================
--- changes.h   (Revision 16573)
+++ changes.h   (Arbeitskopie)
@@ -67,7 +67,7 @@
        ///
 
        /// return the change at the given pos
-       Change const lookup(pos_type pos) const;
+       Change const & lookup(pos_type pos) const;
 
        /// return true if there is a change in the given range (excluding end)
        bool isChanged(pos_type start, pos_type end) const;
@@ -90,10 +90,14 @@
                        : start(s), end(e) {}
 
                // does this range contain r ?
-               bool contains(Range const & r) const;
+               bool contains(Range const & r) const {
+                       return r.start >= start && r.end <= end;
+               }
 
                // does this range contain pos ?
-               bool contains(pos_type pos) const;
+               bool contains(pos_type pos) const {
+                       return pos >= start && pos < end;
+               }
 
                // do the ranges intersect ?
                bool intersects(Range const & r) const;

Reply via email to