Jean-Marc Lasgouttes a écrit :
"Juergen" == Juergen Spitzmueller <[EMAIL PROTECTED]> writes:
Juergen> Jean-Marc Lasgouttes wrote:
Not surprising, too much cut and paste.
Try that instead.
Juergen> Not much different (perhaps a bit faster, hard to say).
I see a big difference in gprof, but this is probably because it does
not take IO time into account. This is a patch that should go in at
some time, so I keep it somewhere.
Just for your info, it seems that there is a _very_ small improvement
under windows for paragraph creation/deletion.
Out of interest I tried the following patch to understand how I can
speedup updateCounter. This is _not_ proposed for inclusion, I
understand this is not practical for inside inset numbering.
Well, the good news is that, with this patch, paragraph
creation/deletion is _instantaneous_ (even with fast key+enter
repetition). I guess this is normal (and this is the bad news) because
the section are not numbered so setCounter() doesn't seem to work with
the ParIterator I am giving to it.
I first tried to use the "ParIterator(InsetBase &, lyx::pit_type pit)"
constructor but this one is not implemented.
Question: what does it take (except for "it.pos()=i") to have a valid
ParIterator at position i in my code?
Abdel.
Index: src/buffer_funcs.C
===================================================================
--- src/buffer_funcs.C (revision 13525)
+++ src/buffer_funcs.C (working copy)
@@ -503,11 +503,11 @@
} // anon namespace
-void updateCounters(Buffer const & buf)
+void updateCounters(Buffer & buf)
{
// start over
buf.params().getLyXTextClass().counters().reset();
-
+/*
for (ParIterator it = par_iterator_begin(buf.inset()); it; ++it) {
// reduce depth if necessary
if (it.pit()) {
@@ -520,6 +520,30 @@
// set the counter for this paragraph
setCounter(buf, it);
}
+ */
+
+ ParagraphList & pars = buf.paragraphs();
+
+ pars[0].params().depth(0);
+
+ ParIterator it = par_iterator_begin(buf.inset());
+
+ for (size_t i = 1; i != pars.size(); ++i)
+ {
+ // reduce depth if necessary
+ Paragraph const & prevpar = pars[i - 1];
+ Paragraph & par = pars[i];
+ par.params().depth(min(par.params().depth(),
+ prevpar.getMaxDepthAfter()));
+
+ // This constructor is in the header but not implemented:
+ //ParIterator it(buf.inset(), i);
+
+ it.pos() = i;
+
+ // set the counter for this paragraph
+ setCounter(buf, it);
+ }
}
Index: src/buffer_funcs.h
===================================================================
--- src/buffer_funcs.h (revision 13525)
+++ src/buffer_funcs.h (working copy)
@@ -49,7 +49,7 @@
bool appendix);
/// updates all counters
-void updateCounters(Buffer const &);
+void updateCounters(Buffer &);
#endif // BUFFER_FUNCS_H