I used sometime yesterday evening to run gprof with large tables, and
came up with the following patch. I posted it here instead of applying
because it seems so obvious that I suspect I may have misunderstood
something.
The two main problems are:
- InsetTabular::clone() duplicates its LyXTabular twice
- Paragraph::Paragraph(const &Paragraph) all in all builds three
ParagraphParameters instances, whereas none is needed, since the
whole point of share_ptr IMO is reference counting.
Lars, Juergen, could you have a look and confirm that I am not wrong?
It may not have the huge impact that some mystery projects will have,
but it seems much saner (and LyX is certainly faster with that).
Also, somethig that shows up in gprof output is insettext::getLyXText.
Why the hell does this function use a map?? I understand that maps are
constant time, but did you ever wondered how many entries are there?
For now I would say 1, in the future certainly less that 10. I really
doubt that a map will ever be faster than a list or whatever. Further,
why do we pass a BufferView* to most insettext methods, whereas most
of the times it just calls TEXT(bv)? Why not have the LyXText as
parameter?
JMarc
diff -ur -x Makefile.in -x ext_l10n.h lyx-devel.orig/src/insets/insettabular.C
lyx-devel/src/insets/insettabular.C
--- lyx-devel.orig/src/insets/insettabular.C Thu Jun 28 12:53:46 2001
+++ lyx-devel/src/insets/insettabular.C Fri Jun 29 00:38:43 2001
@@ -160,7 +160,8 @@
Inset * InsetTabular::clone(Buffer const & buf) const
{
InsetTabular * t = new InsetTabular(*this, buf);
- t->tabular.reset(tabular->clone(t));
+#warning Juergen, this this done already in the InsetTabular ctor, methink (JMarc)
+ //t->tabular.reset(tabular->clone(t));
return t;
}
diff -ur -x Makefile.in -x ext_l10n.h lyx-devel.orig/src/paragraph.C
lyx-devel/src/paragraph.C
--- lyx-devel.orig/src/paragraph.C Thu Jun 28 12:53:31 2001
+++ lyx-devel/src/paragraph.C Fri Jun 29 00:01:40 2001
@@ -115,9 +115,10 @@
itemdepth = 0;
next_ = 0;
previous_ = 0;
- clear();
+ //clear();
- makeSameLayout(&lp);
+ layout = lp.layout;
+ //makeSameLayout(&lp);
// this is because of the dummy layout of the paragraphs that
// follow footnotes
@@ -921,10 +922,11 @@
void Paragraph::makeSameLayout(Paragraph const * par)
{
layout = par->layout;
- params().makeSame(par->params());
+ //params().makeSame(par->params());
+ params() = par->params();
// This can be changed after NEW_INSETS is in effect. (Lgb)
- setLabelWidthString(par->params().labelWidthString());
+ //setLabelWidthString(par->params().labelWidthString());
}
diff -ur -x Makefile.in -x ext_l10n.h lyx-devel.orig/src/paragraph_pimpl.C
lyx-devel/src/paragraph_pimpl.C
--- lyx-devel.orig/src/paragraph_pimpl.C Thu Jun 28 14:56:17 2001
+++ lyx-devel/src/paragraph_pimpl.C Fri Jun 29 00:12:53 2001
@@ -40,7 +40,7 @@
Paragraph::Pimpl::Pimpl(Paragraph::Pimpl const & p, Paragraph * owner)
- : owner_(owner)
+ : params(p.params), owner_(owner)
{
inset_owner = p.inset_owner;
text = p.text;