From: André Pönitz Date: Sat, 16 Jul 2005 18:25:58 +0000 (+0000) Subject: some more inlining X-Git-Tag: 1.6.10~14080 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=372365845df7615b7b40db143d82b14cc98bb902;p=features.git some more inlining git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10259 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt2/qfont_loader.C b/src/frontends/qt2/qfont_loader.C index 026a9a599e..f15ee0de40 100644 --- a/src/frontends/qt2/qfont_loader.C +++ b/src/frontends/qt2/qfont_loader.C @@ -310,12 +310,11 @@ FontInfo::FontInfo(LyXFont const & f) << font.pointSizeFloat() << endl; // Is this an exact match? - if (font.exactMatch()) { + if (font.exactMatch()) lyxerr[Debug::FONT] << "This font is an exact match" << endl; - } else { + else lyxerr[Debug::FONT] << "This font is NOT an exact match" << endl; - } lyxerr[Debug::FONT] << "XFLD: " << font.rawName() << endl; @@ -328,7 +327,6 @@ int FontInfo::width(Uchar val) const // Starting with version 3.1.0, Qt/X11 does its own caching of // character width, so it is not necessary to provide ours. #if defined (USE_LYX_FONTCACHE) -#error xxx FontInfo::WidthCache::const_iterator cit = widthcache.find(val); if (cit != widthcache.end()) return cit->second; diff --git a/src/frontends/qt2/qfont_loader.h b/src/frontends/qt2/qfont_loader.h index c0b401547e..7447e0189f 100644 --- a/src/frontends/qt2/qfont_loader.h +++ b/src/frontends/qt2/qfont_loader.h @@ -34,40 +34,40 @@ class FontInfo { public: FontInfo(LyXFont const & f); - /// return pixel width for the given unicode char + /// Return pixel width for the given unicode char int width(Uchar val) const; - /// the font instance + /// The font instance QFont font; - /// metrics on the font + /// Metrics on the font QFontMetrics metrics; #if defined(USE_LYX_FONTCACHE) typedef std::map WidthCache; - /// cache of char widths + /// Cache of char widths WidthCache widthcache; #endif }; +/// Hold info about a particular font class FontLoader { public: - /// hold info about a particular font /// FontLoader(); - /// update fonts after zoom, dpi, font names, or norm change + /// Update fonts after zoom, dpi, font names, or norm change void update(); - /// do we have anything matching? + /// Do we have anything matching? bool available(LyXFont const & f); - /// get the QFont for this LyXFont + /// Get the QFont for this LyXFont QFont const & get(LyXFont const & f) { return fontinfo(f).font; } - /// get the QFont metrics for this LyXFont + /// Get the QFont metrics for this LyXFont QFontMetrics const & metrics(LyXFont const & f) { return fontinfo(f).metrics; } @@ -78,7 +78,7 @@ public: /// Called the first time when available() can't load a symbol font static void addToFontPath(); - /// get font info (font + metrics) for the given LyX font. Does not fail. + /// Get font info (font + metrics) for the given LyX font. FontInfo & fontinfo(LyXFont const & f) { FontInfo * & fi = fontinfo_[f.family()][f.series()][f.realShape()][f.size()]; diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index e86c1d305b..1bdec8e659 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -743,18 +743,19 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd) row_type rs, re; col_type cs, ce; getSelection(cur, rs, re, cs, ce); - for (row_type i = rs; i <= re; ++i) + for (row_type i = rs; i <= re; ++i) { for (col_type j = cs; j <= ce; ++j) { // cursor follows cell: cur.idx() = tabular.getCellNumber(i, j); // select this cell only: cur.pos() = 0; - cur.resetAnchor(); + cur.resetAnchor(); cur.pos() = cur.top().lastpos(); - cur.setCursor(cur); - cur.setSelection(); + cur.setCursor(cur); + cur.setSelection(); cell(cur.idx())->dispatch(cur, cmd); } + } // Restore original selection cur.idx() = tabular.getCellNumber(rs, cs); cur.pos() = 0; diff --git a/src/lyxfont.C b/src/lyxfont.C index 6fefc131c9..d7559ca084 100644 --- a/src/lyxfont.C +++ b/src/lyxfont.C @@ -204,12 +204,6 @@ LColor_color LyXFont::color() const } -Language const * LyXFont::language() const -{ - return lang; -} - - bool LyXFont::isRightToLeft() const { return lang->RightToLeft(); @@ -917,23 +911,6 @@ LColor_color LyXFont::realColor() const } -// Convert logical attributes to concrete shape attribute -LyXFont::FONT_SHAPE LyXFont::realShape() const -{ - register FONT_SHAPE s = shape(); - - if (emph() == ON) { - if (s == UP_SHAPE) - s = ITALIC_SHAPE; - else - s = UP_SHAPE; - } - if (noun() == ON) - s = SMALLCAPS_SHAPE; - return s; -} - - ostream & operator<<(ostream & os, LyXFont::FONT_MISC_STATE fms) { return os << int(fms); diff --git a/src/lyxfont.h b/src/lyxfont.h index 58943b749b..8d0d3a2610 100644 --- a/src/lyxfont.h +++ b/src/lyxfont.h @@ -221,7 +221,7 @@ public: /// LColor_color color() const; /// - Language const * language() const; + Language const * language() const { return lang; } /// bool isRightToLeft() const; /// @@ -319,7 +319,15 @@ public: std::ostream & operator<<(std::ostream & os, LyXFont const & font); /// Converts logical attributes to concrete shape attribute - LyXFont::FONT_SHAPE realShape() const; + // Try hard to inline this as it shows up with 4.6 % in the profiler. + LyXFont::FONT_SHAPE realShape() const { + if (bits.noun == ON) + return SMALLCAPS_SHAPE; + if (bits.emph == ON) + return (bits.shape == UP_SHAPE) ? ITALIC_SHAPE : UP_SHAPE; + return bits.shape; + } + /** Compaq cxx 6.5 requires that the definition be public so that it can compile operator==() diff --git a/src/paragraph.h b/src/paragraph.h index b16ac0d5b0..36739946f9 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -302,18 +302,16 @@ public: LyXFont const & font); /// void insertChar(lyx::pos_type pos, value_type c, - Change change = Change(Change::INSERTED)); + Change change = Change::INSERTED); /// void insertChar(lyx::pos_type pos, value_type c, - LyXFont const &, Change change = Change(Change::INSERTED)); - /// - bool checkInsertChar(LyXFont &); + LyXFont const &, Change change = Change::INSERTED); /// void insertInset(lyx::pos_type pos, InsetBase * inset, - Change change = Change(Change::INSERTED)); + Change change = Change::INSERTED); /// void insertInset(lyx::pos_type pos, InsetBase * inset, - LyXFont const &, Change change = Change(Change::INSERTED)); + LyXFont const &, Change change = Change::INSERTED); /// bool insetAllowed(InsetBase_code code); /// @@ -327,7 +325,9 @@ public: /// bool isHfill(lyx::pos_type pos) const; /// hinted by profiler - bool isInset(lyx::pos_type pos) const { return getChar(pos) == static_cast(META_INSET); } + bool isInset(lyx::pos_type pos) const { + return getChar(pos) == static_cast(META_INSET); + } /// bool isNewline(lyx::pos_type pos) const; /// @@ -367,7 +367,9 @@ public: unsigned int height() const { return dim_.height(); } /// total width of paragraph, may differ from workwidth unsigned int width() const { return dim_.width(); } + /// ascend of paragraph above baseline unsigned int ascent() const { return dim_.ascent(); } + /// descend of paragraph below baseline unsigned int descent() const { return dim_.descent(); } /// LyXText updates the rows using this access point RowList & rows() { return rows_; }