Why do we have this distinction? Performance? Proven?

// Gets the fully instantiated font at a given position in a paragraph
// Basically the same routine as Paragraph::getFont() in paragraph.C.
// The difference is that this one is used for displaying, and thus we
// are allowed to make cosmetic improvements. For instance make footnotes
// smaller. (Asger)
// If position is -1, we get the layout font of the paragraph.
// If position is -2, we get the font of the manual label of the paragraph.
LyXFont const LyXText::getFont(Buffer const * buf, ParagraphList::iterator pit,
                               pos_type pos) const
{
        Assert(pos >= 0);

        LyXLayout_ptr const & layout = pit->layout();

        // We specialize the 95% common case:
        if (!pit->getDepth()) {
                if (layout->labeltype == LABEL_MANUAL
                    && pos < pit->beginningOfBody()) {
                        // 1% goes here
                        LyXFont f = pit->getFontSettings(buf->params, pos);
                        if (pit->inInset())
                                pit->inInset()->getDrawFont(f);
                        return f.realize(layout->reslabelfont);
                } else {
                        LyXFont f = pit->getFontSettings(buf->params, pos);
                        if (pit->inInset())
                                pit->inInset()->getDrawFont(f);
                        return f.realize(layout->resfont);
                }
        }

        // The uncommon case need not be optimized as much

        LyXFont layoutfont;

        if (pos < pit->beginningOfBody()) {
                // 1% goes here
                layoutfont = layout->labelfont;
        } else {
                // 99% goes here
                layoutfont = layout->font;
        }

        LyXFont tmpfont = pit->getFontSettings(buf->params, pos);
        tmpfont.realize(layoutfont);

        if (pit->inInset())
                pit->inInset()->getDrawFont(tmpfont);

        // Realize with the fonts of lesser depth.
        tmpfont.realize(outerFont(pit, ownerParagraphs()));

        return realizeFont(tmpfont, buf->params);
}

Reply via email to