From 28ef49f2d9206c4d96230c395a7712185bd5d120 Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Mon, 14 Aug 2006 09:33:49 +0000 Subject: [PATCH] * src/buffer.C (Buffer::errorList): simplify * src/buffer.h emptyErrorList_ move to buffer.C and make it static const * src/lyx_main.C (LyX::exec2): Use for_each instead of for loop git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14667 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/buffer.C | 11 +++-------- src/buffer.h | 3 --- src/lyx_main.C | 13 +++---------- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/buffer.C b/src/buffer.C index 367ef539a6..fd50d05017 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -1703,9 +1703,10 @@ void Buffer::getSourceCode(ostream & os, lyx::pit_type par_begin, lyx::pit_type ErrorList const & Buffer::errorList(string const & type) const { + static ErrorList const emptyErrorList; std::map::const_iterator I = errorLists_.find(type); if (I == errorLists_.end()) - return emptyErrorList_; + return emptyErrorList; return I->second; } @@ -1713,11 +1714,5 @@ ErrorList const & Buffer::errorList(string const & type) const ErrorList & Buffer::errorList(string const & type) { - std::map::iterator I = errorLists_.find(type); - if (I == errorLists_.end()) { - errorLists_[type] = emptyErrorList_; - return errorLists_[type]; - } - - return I->second; + return errorLists_[type]; } diff --git a/src/buffer.h b/src/buffer.h index 429d0ac1cc..f26e6a6fee 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -387,9 +387,6 @@ private: /// Container for all sort of Buffer dependant errors. std::map errorLists_; - - /// Empty Error List - ErrorList const emptyErrorList_; }; #endif diff --git a/src/lyx_main.C b/src/lyx_main.C index 9f3dddbb92..2cc5eccd16 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -83,7 +83,6 @@ namespace fs = boost::filesystem; using std::endl; using std::string; using std::vector; -using std::mem_fun_ref; #ifndef CXX_GLOBAL_CSTD using std::exit; @@ -283,15 +282,9 @@ int LyX::exec2(int & argc, char * argv[]) if (loadLyXFile(buf, s)) { last_loaded = buf; ErrorList const & el = buf->errorList("Parse"); - if (!el.empty()) { - // There should be a way to use the following but I (abdel) don't know - // how to make it compile on MSVC2005. - //for_each(el.begin(), el.end(), mem_fun_ref(&LyX::printError)); - for (ErrorList::const_iterator it = el.begin(); - it != el.end(); ++it) { - printError(*it); - } - } + if (!el.empty()) + for_each(el.begin(), el.end(), + boost::bind(&LyX::printError, this, _1)); } else bufferlist.release(buf); -- 2.39.2