X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyxtextclass.C;h=3df1271e40147b24f52fe9389a143c5a5d2380cb;hb=fe390e9da1538e20eabbc98977d845295f8e563d;hp=f406915a858adc943093c714759d3e768885ea3b;hpb=ff98dcea08c23fe70daf8877fb05593e3262057d;p=lyx.git diff --git a/src/lyxtextclass.C b/src/lyxtextclass.C index f406915a85..3df1271e40 100644 --- a/src/lyxtextclass.C +++ b/src/lyxtextclass.C @@ -24,6 +24,8 @@ #include +using namespace lyx::support; + using std::endl; using std::find_if; using std::remove_if; @@ -753,20 +755,9 @@ bool LyXTextClass::hasLayout(string const & n) const -LyXLayout_ptr const & LyXTextClass::operator[](string const & n) const +LyXLayout_ptr const & LyXTextClass::operator[](string const & name) const { - lyx::Assert(!n.empty()); - - if (n.empty()) - lyxerr << "LyXTextClass::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]; + Assert(!name.empty()); LayoutList::const_iterator cit = find_if(layoutlist_.begin(), @@ -782,12 +773,9 @@ LyXLayout_ptr const & LyXTextClass::operator[](string const & n) const lyxerr << " " << it->get()->name() << endl; // we require the name to exist - lyx::Assert(false); + Assert(false); } - lastLayoutName = name; - lastLayoutIndex = std::distance(layoutlist_.begin(), cit); - return (*cit); }