]> git.lyx.org Git - lyx.git/commitdiff
optimization
authorLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 12 Mar 2002 18:11:49 +0000 (18:11 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 12 Mar 2002 18:11:49 +0000 (18:11 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3736 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/lyxtextclass.C

index 914f1ed4ca325ea31f4193e2d3aec3a60c4e940f..6d9721a6029741606b400aeb1b3dc4b4600dd187 100644 (file)
@@ -1,5 +1,7 @@
 2002-03-12  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
+       * lyxtextclass.C (operator): add one item cache optimization.
+
        * bufferlist.h: doxy changes
 
        * bufferlist.C: ws changes
index 6c368bb7b89edd7a653f2e4af6eaeeaa43769749..7f6a668ff464adfee5de6161a4246f86ccfaf8d6 100644 (file)
@@ -512,6 +512,13 @@ LyXLayout const & LyXTextClass::operator[](string const & n) const
                lyxerr << "Operator[] called with empty n" << endl;
        
        string const name = (n.empty() ? defaultLayoutName() : n);
+
+       static string lastLayoutName;
+       static LayoutList::difference_type lastLayoutIndex;
+
+       if (name == lastLayoutName)
+               return layoutlist[lastLayoutIndex];
+
        
        LayoutList::const_iterator cit =
                find_if(layoutlist.begin(),
@@ -527,6 +534,9 @@ LyXLayout const & LyXTextClass::operator[](string const & n) const
                lyx::Assert(false);
        }
 
+       lastLayoutName = name;
+       lastLayoutIndex = std::distance(layoutlist.begin(), cit);
+       
        return *cit;
 }