From 672ab4213766b1dc2599edf89436083e1144fb59 Mon Sep 17 00:00:00 2001 From: Asger Ottar Alstrup Date: Sun, 27 Jul 2003 00:37:17 +0000 Subject: [PATCH] Work to improve performance a bit git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7373 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 9 +++++++++ src/insets/inset.C | 1 - src/rowpainter.C | 1 - src/text.C | 31 ++++++++++++++++--------------- src/text2.C | 13 ++++++------- 5 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 8f2cf258ef..c1e29d1852 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2003-07-26 Asger Alstrup + + * text2.C (metrics): change a brain-dead algorithm to a smarter one. + + * text.C (singleWidth): Spurious font copying in hot-spot + singleWidth avoided. Reorder tests for arabic for efficiency. + + * text.C (fill): handle empty paragraphs better. + 2003-07-27 Jean-Marc Lasgouttes * ispell.C: diff --git a/src/insets/inset.C b/src/insets/inset.C index 24db8ed946..07fe683d1e 100644 --- a/src/insets/inset.C +++ b/src/insets/inset.C @@ -48,7 +48,6 @@ InsetOld::InsetOld(InsetOld const & in) top_x(0), top_baseline(0), scx(0), id_(in.id_), owner_(0), name_(in.name_), background_color_(in.background_color_) { - lyxerr << "inset id: " << id_ << std::endl; } diff --git a/src/rowpainter.C b/src/rowpainter.C index 4077d6ee0b..e4cdfb3e85 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -1076,7 +1076,6 @@ void paintRows(BufferView const & bv, LyXText const & text, // calling metrics() directly is (a) slow and (b) crashs if (&text == bv.text) { #if 1 - lyxerr << "paintRows, global...\n"; // make sure all insets are updated ParagraphList::iterator pit = text.ownerParagraphs().begin(); ParagraphList::iterator end = text.ownerParagraphs().end(); diff --git a/src/text.C b/src/text.C index a35e9cf4ef..8552f65777 100644 --- a/src/text.C +++ b/src/text.C @@ -284,14 +284,14 @@ int LyXText::singleWidth(ParagraphList::iterator pit, if (pos >= pit->size()) return 0; - LyXFont const font = getFont(bv()->buffer(), pit, pos); + LyXFont const & font = getFont(bv()->buffer(), pit, pos); // The most common case is handled first (Asger) if (IsPrintable(c)) { if (font.language()->RightToLeft()) { - if (font.language()->lang() == "arabic" && - (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 || - lyxrc.font_norm_type == LyXRC::ISO_10646_1)) { + if ((lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 || + lyxrc.font_norm_type == LyXRC::ISO_10646_1) + && font.language()->lang() == "arabic") { if (Encodings::IsComposeChar_arabic(c)) return 0; else @@ -301,7 +301,6 @@ int LyXText::singleWidth(ParagraphList::iterator pit, return 0; } return font_metrics::width(c, font); - } if (c == Paragraph::META_INSET) { @@ -935,17 +934,19 @@ int LyXText::fill(RowList::iterator row, int paper_width) const pos_type const body_pos = pit->beginningOfBody(); pos_type i = row->pos(); - while (i <= last) { - if (body_pos > 0 && i == body_pos) { - w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), pit)); - if (pit->isLineSeparator(i - 1)) - w -= singleWidth(pit, i - 1); - int left_margin = labelEnd(*row); - if (w < left_margin) - w = left_margin; + if (! pit->empty()) { + while (i <= last) { + if (body_pos > 0 && i == body_pos) { + w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), pit)); + if (pit->isLineSeparator(i - 1)) + w -= singleWidth(pit, i - 1); + int left_margin = labelEnd(*row); + if (w < left_margin) + w = left_margin; + } + w += singleWidth(pit, i); + ++i; } - w += singleWidth(pit, i); - ++i; } if (body_pos > 0 && body_pos > last) { w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), pit)); diff --git a/src/text2.C b/src/text2.C index e2eb79e108..0231873fdb 100644 --- a/src/text2.C +++ b/src/text2.C @@ -711,13 +711,12 @@ void LyXText::metrics(MetricsInfo & mi, Dimension & dim) ParagraphList::iterator end = ownerParagraphs().end(); for (; pit != end; ++pit) { - // compute inset metrics - for (int pos = 0; pos != pit->size(); ++pos) { - if (pit->isInset(pos)) { - Dimension dim; - MetricsInfo m = mi; - pit->getInset(pos)->metrics(m, dim); - } + InsetList::iterator ii = pit->insetlist.begin(); + InsetList::iterator iend = pit->insetlist.end(); + for (; ii != iend; ++ii) { + Dimension dim; + MetricsInfo m = mi; + ii->inset->metrics(m, dim); } // insert a new row, starting at position 0 -- 2.39.2