Reduce number of calls to TabularInset::metrics
Index: metricsinfo.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/metricsinfo.C,v retrieving revision 1.2 diff -u -p -r1.2 metricsinfo.C --- metricsinfo.C 28 May 2003 13:22:33 -0000 1.2 +++ metricsinfo.C 17 Jul 2003 08:22:30 -0000 @@ -16,10 +16,20 @@ MetricsBase::MetricsBase() +MetricsBase::MetricsBase(BufferView * b, LyXFont const & f) + : bv(b), font(f), style(LM_ST_TEXT), fontname("mathnormal"), + restrictwidth(false), textwidth(0) +{} + + MetricsInfo::MetricsInfo() {} + +MetricsInfo::MetricsInfo(BufferView * bv, LyXFont const & font) + : base(bv, font) +{} Index: metricsinfo.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/metricsinfo.h,v retrieving revision 1.2 diff -u -p -r1.2 metricsinfo.h --- metricsinfo.h 28 May 2003 13:22:33 -0000 1.2 +++ metricsinfo.h 17 Jul 2003 08:22:30 -0000 @@ -27,6 +27,8 @@ enum Styles { struct MetricsBase { /// MetricsBase(); + /// + MetricsBase(BufferView * bv, LyXFont const & font); /// the current view BufferView * bv; @@ -50,6 +52,8 @@ struct MetricsBase { struct MetricsInfo { /// MetricsInfo(); + /// + MetricsInfo(BufferView * bv, LyXFont const & font); /// MetricsBase base; Index: insets/inset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/inset.C,v retrieving revision 1.101 diff -u -p -r1.101 inset.C --- insets/inset.C 30 Jun 2003 23:56:17 -0000 1.101 +++ insets/inset.C 17 Jul 2003 08:22:30 -0000 @@ -145,9 +145,7 @@ int Inset::latexTextWidth(BufferView * b int Inset::ascent(BufferView * bv, LyXFont const & font) const { Dimension dim; - MetricsInfo mi; - mi.base.bv = bv; - mi.base.font = font; + MetricsInfo mi(bv, font); metrics(mi, dim); return dim.ascent(); } @@ -156,9 +154,7 @@ int Inset::ascent(BufferView * bv, LyXFo int Inset::descent(BufferView * bv, LyXFont const & font) const { Dimension dim; - MetricsInfo mi; - mi.base.bv = bv; - mi.base.font = font; + MetricsInfo mi(bv, font); metrics(mi, dim); return dim.descent(); } @@ -167,9 +163,7 @@ int Inset::descent(BufferView * bv, LyXF int Inset::width(BufferView * bv, LyXFont const & font) const { Dimension dim; - MetricsInfo mi; - mi.base.bv = bv; - mi.base.font = font; + MetricsInfo mi(bv, font); metrics(mi, dim); return dim.width(); } Index: insets/insettabular.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v retrieving revision 1.300 diff -u -p -r1.300 insettabular.C --- insets/insettabular.C 17 Jul 2003 07:43:55 -0000 1.300 +++ insets/insettabular.C 17 Jul 2003 08:22:30 -0000 @@ -1245,10 +1245,11 @@ bool InsetTabular::calculate_dimensions_ if ((need_update != INIT) && (the_locking_inset == tabular.getCellInset(actcell))) { for(int i = 0; i < tabular.columns(); ++i) { - maxAsc = max(tabular.getCellInset(actrow, i)->ascent(bv, font), - maxAsc); - maxDesc = max(tabular.getCellInset(actrow, i)->descent(bv, font), - maxDesc); + Dimension dim; + MetricsInfo mi(bv, font); + tabular.getCellInset(actrow, i)->metrics(mi, dim); + maxAsc = max(dim.asc, maxAsc); + maxDesc = max(dim.des, maxDesc); } changed = tabular.setWidthOfCell(actcell, the_locking_inset->width(bv, font)); changed = tabular.setAscentOfRow(actrow, maxAsc + ADD_TO_HEIGHT) || changed; @@ -1262,10 +1263,12 @@ bool InsetTabular::calculate_dimensions_ if (tabular.isPartOfMultiColumn(i,j)) continue; ++cell; - inset = tabular.getCellInset(cell); - maxAsc = max(maxAsc, inset->ascent(bv, font)); - maxDesc = max(maxDesc, inset->descent(bv, font)); - changed = tabular.setWidthOfCell(cell, inset->width(bv, font)) || changed; + Dimension dim; + MetricsInfo mi(bv, font); + tabular.getCellInset(cell)->metrics(mi, dim); + maxAsc = max(maxAsc, dim.asc); + maxDesc = max(maxDesc, dim.des); + changed = tabular.setWidthOfCell(cell, dim.wid) || changed; } changed = tabular.setAscentOfRow(i, maxAsc + ADD_TO_HEIGHT) || changed; changed = tabular.setDescentOfRow(i, maxDesc + ADD_TO_HEIGHT) || changed;