On 18/12/2010 22:03, Bernhard Roider wrote:
2010/12/18 Abdelrazak Younes <you...@lyx.org <mailto:you...@lyx.org>>
On 18/12/2010 19:33, Jean-Marc Lasgouttes wrote:
Le 18 déc. 2010 à 19:08, Abdelrazak Younes a écrit :
On 18/12/2010 18:57, Jean-Marc Lasgouttes wrote:
Le 18 déc. 2010 à 17:41, Abdelrazak Younes a écrit :
What part of that could possibly go to branch?
I guess introducing RandomListAccess::position()
and using it will be enough.
Why does this remove the quadratic behaviour?
distance(it1, it2) = paragraphs.position(it2) -
paragraphs.position(it1);
But position() is linear, like std::distance().
std::distance() advances the std::list iterator while
RandomAccessList::position() look for the std::list iterator
copies. The copies are in a vector so I assume this is faster.
But as I said before, maybe the fix is as simple as this:
- if (distance(lastpar, par)>= distance(lastpar,
endpar))
+
+ if (par == endpar)
break;
I thought this broke source view.
endpar is either paragraphs.end() or is given by the source view
so it should work.
Abdel.
Hello Abdel,
i didn't look into the code but following your arguments in this
thread there seems to be a problem:
- TeXOnePar may jump by more than one par
No, TeXOnePar advances only one par at a time. But yes, TeXEnvironment
will in general jump by more than one par. There is by the way a bug in
branch in that TeXEnvironment do not check for endpar but only
paragraphs.end().
- endpar is either paragraphs.end() or is given by the source view
if this is true then the condition par == endpar is wrong because
your earlier argument "... it can't go above paragraphs.end(), there's
nothing above" doesn't hold because there can be something above endpar.
Well maybe, but because of the bug in TeXEnvironment described above,
maybe not. But yes, I guess you're right, better be safe in branch so
here is a better patch for branch (untested).
Abdel.
Index: output_latex.cpp
===================================================================
--- output_latex.cpp (revision 36930)
+++ output_latex.cpp (working copy)
@@ -811,8 +811,9 @@
ParagraphList::const_iterator endpar = paragraphs.end();
LASSERT(runparams.par_begin <= runparams.par_end, /**/);
+ bool const full_export = runparams.par_begin == runparams.par_end;
// if only part of the paragraphs will be outputed
- if (runparams.par_begin != runparams.par_end) {
+ if (!full_export) {
par = boost::next(paragraphs.begin(), runparams.par_begin);
endpar = boost::next(paragraphs.begin(), runparams.par_end);
// runparams will be passed to nested paragraphs, so
@@ -892,8 +893,13 @@
par = TeXOnePar(buf, text, par, os, texrow,
runparams, everypar);
}
- if (distance(lastpar, par) >= distance(lastpar, endpar))
+
+ if (full_export) {
+ if (par == paragraphs.end())
+ break;
+ } else if (distance(lastpar, par) >= distance(lastpar, endpar))
{
break;
+ }
}
// It might be that we only have a title in this document