From ca91d508b2a33d105b1eecf3ac086104213bb47a Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Sat, 18 Dec 2010 07:37:12 +0000 Subject: [PATCH] LaTeX export small speedup: Introduce RandomAccessList::position() and use it. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36931 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/output_latex.cpp | 6 +++--- src/support/RandomAccessList.h | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/output_latex.cpp b/src/output_latex.cpp index 4f39ee58d7..cc56d6b672 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -413,7 +413,7 @@ void TeXOnePar(Buffer const & buf, } if (text.inset().getLayout().isPassThru()) { - int const dist = distance(paragraphs.begin(), pit); + int const dist = paragraphs.position(pit); Font const outerfont = text.outerFont(dist); // No newline before first paragraph in this lyxtext @@ -432,7 +432,7 @@ void TeXOnePar(Buffer const & buf, } if (style.pass_thru) { - int const dist = distance(paragraphs.begin(), pit); + int const dist = paragraphs.position(pit); Font const outerfont = text.outerFont(dist); pit->latex(bparams, outerfont, os, texrow, runparams, start_pos, end_pos); @@ -690,7 +690,7 @@ void TeXOnePar(Buffer const & buf, break; } - Font const outerfont = text.outerFont(distance(paragraphs.begin(), pit)); + Font const outerfont = text.outerFont(paragraphs.position(pit)); // FIXME UNICODE os << from_utf8(everypar); diff --git a/src/support/RandomAccessList.h b/src/support/RandomAccessList.h index 7b0f1032dd..4c48b36db2 100644 --- a/src/support/RandomAccessList.h +++ b/src/support/RandomAccessList.h @@ -273,6 +273,26 @@ public: iterCont_.clear(); } + size_t position(iterator it) const + { + size_t const s = iterCont_.size(); + for (size_t i = 0; it != s; ++i) { + if (iterCont_[i] == it) + return i; + } + return s; + } + + size_t position(const_iterator it) const + { + size_t const s = iterCont_.size(); + for (size_t i = 0; i != s; ++i) { + if (iterCont_[i] == it) + return i; + } + return s; + } + private: void recreateVector() { -- 2.39.5