commit b627b8701b6598f5402cbab55a83026c9e3b1e86
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Tue Feb 24 10:17:45 2015 +0100

    Some performance stuff reported by cppcheck

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index b8e233a..f6af77d 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -1851,7 +1851,7 @@ void Buffer::writeDocBookSource(odocstream & os, string 
const & fname,
        d->texrow.reset();
 
        DocumentClass const & tclass = params().documentClass();
-       string const top_element = tclass.latexname();
+       string const & top_element = tclass.latexname();
 
        bool const output_preamble =
                output == FullSource || output == OnlyPreamble;
diff --git a/src/LyX.cpp b/src/LyX.cpp
index 8b75b44..f06b970 100644
--- a/src/LyX.cpp
+++ b/src/LyX.cpp
@@ -763,7 +763,7 @@ void cleanDuplicateEnvVars()
        }
 
        // Loop over the list of duplicated variables
-       for (std::set<std::string>::iterator dupe = dupes.begin(); dupe != 
dupes.end(); dupe++) {
+       for (std::set<std::string>::iterator dupe = dupes.begin(); dupe != 
dupes.end(); ++dupe) {
                const char *name = (*dupe).c_str();
                char *val = getenv(name);
                if (val != NULL) {
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 8ee06ea..0570753 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -620,7 +620,7 @@ bool Paragraph::isMergedOnEndOfParDeletion(bool 
trackChanges) const
        if (!trackChanges)
                return true;
 
-       Change const change = d->changes_.lookup(size());
+       Change const & change = d->changes_.lookup(size());
        return change.inserted() && change.currentAuthor();
 }
 
@@ -1640,7 +1640,7 @@ void Paragraph::write(ostream & os, BufferParams const & 
bparams,
        int column = 0;
        for (pos_type i = 0; i <= size(); ++i) {
 
-               Change const change = lookupChange(i);
+               Change const & change = lookupChange(i);
                if (change != running_change)
                        flushString(os, write_buffer);
                Changes::lyxMarkChange(os, bparams, column, running_change, 
change);
diff --git a/src/Text.cpp b/src/Text.cpp
index a2ae1ae..a448a5c 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -113,8 +113,8 @@ static bool moveItem(Paragraph & fromPar, pos_type fromPos,
        // Therefore, it should only be used for breaking and merging paragraphs
 
        // We need a copy here because the character at fromPos is going to be 
erased.
-       Font const tmpFont = fromPar.getFontSettings(params, fromPos);
-       Change const tmpChange = fromPar.lookupChange(fromPos);
+       Font const & tmpFont = fromPar.getFontSettings(params, fromPos);
+       Change const & tmpChange = fromPar.lookupChange(fromPos);
 
        if (Inset * tmpInset = fromPar.getInset(fromPos)) {
                fromPar.releaseInset(fromPos);
@@ -2057,11 +2057,11 @@ void Text::charsTranspose(Cursor & cur)
 
        // Store the characters to be transposed (including font information).
        char_type const char1 = par.getChar(pos1);
-       Font const font1 =
+       Font const & font1 =
                par.getFontSettings(cur.buffer()->params(), pos1);
 
        char_type const char2 = par.getChar(pos2);
-       Font const font2 =
+       Font const & font2 =
                par.getFontSettings(cur.buffer()->params(), pos2);
 
        // And finally, we are ready to perform the transposition.
diff --git a/src/Text2.cpp b/src/Text2.cpp
index 4f6a975..2597e35 100644
--- a/src/Text2.cpp
+++ b/src/Text2.cpp
@@ -408,7 +408,7 @@ void Text::toggleFree(Cursor & cur, Font const & font, bool 
toggleall)
        // Try implicit word selection
        // If there is a change in the language the implicit word selection
        // is disabled.
-       CursorSlice const resetCursor = cur.top();
+       CursorSlice const & resetCursor = cur.top();
        bool const implicitSelection =
                font.language() == ignore_language
                && font.fontInfo().number() == FONT_IGNORE
diff --git a/src/Text3.cpp b/src/Text3.cpp
index e2602f0..f49274f 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -476,7 +476,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        cur.noScreenUpdate();
 
        LBUFERR(this == cur.text());
-       CursorSlice const oldTopSlice = cur.top();
+       CursorSlice const & oldTopSlice = cur.top();
        bool const oldBoundary = cur.boundary();
        bool const oldSelection = cur.selection();
        // Signals that, even if needsUpdate == false, an update of the
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 2119f8e..afc7f4e 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -446,7 +446,7 @@ bool TextMetrics::redoParagraph(pit_type const pit)
                MacroContext mc(&buffer, parPos);
                MetricsInfo mi(bv_, font.fontInfo(), w, mc);
                ii->inset->metrics(mi, dim);
-               Dimension const old_dim = pm.insetDimension(ii->inset);
+               Dimension const & old_dim = pm.insetDimension(ii->inset);
                if (old_dim != dim) {
                        pm.setInsetDimension(ii->inset, dim);
                        changed = true;
diff --git a/src/insets/InsetCaption.cpp b/src/insets/InsetCaption.cpp
index 8af9827..ad6ec01 100644
--- a/src/insets/InsetCaption.cpp
+++ b/src/insets/InsetCaption.cpp
@@ -299,7 +299,7 @@ docstring InsetCaption::xhtml(XHTMLStream & xs, 
OutputParams const & rp) const
        if (rp.html_disable_captions)
                return docstring();
        InsetLayout const & il = getLayout();
-       string const tag = il.htmltag();
+       string const & tag = il.htmltag();
        string attr = il.htmlattr();
        if (!type_.empty()) {
                string const our_class = "float-caption-" + type_;
diff --git a/src/insets/InsetCitation.cpp b/src/insets/InsetCitation.cpp
index 8f69799..36dc376 100644
--- a/src/insets/InsetCitation.cpp
+++ b/src/insets/InsetCitation.cpp
@@ -183,7 +183,7 @@ docstring InsetCitation::toolTip(BufferView const & bv, 
int, int) const
 namespace {
 
 
-CitationStyle asValidLatexCommand(string const & input, vector<CitationStyle> 
const valid_styles)
+CitationStyle asValidLatexCommand(string const & input, vector<CitationStyle> 
const & valid_styles)
 {
        CitationStyle cs = valid_styles[0];
        cs.forceUpperCase = false;
diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp
index e9a89cf..f6b699b 100644
--- a/src/insets/InsetListings.cpp
+++ b/src/insets/InsetListings.cpp
@@ -284,7 +284,7 @@ docstring InsetListings::xhtml(XHTMLStream & os, 
OutputParams const & rp) const
        }
 
        InsetLayout const & il = getLayout();
-       string const tag = il.htmltag();
+       string const & tag = il.htmltag();
        string attr = "class ='listings";
        string const lang = params().getParamValue("language");
        if (!lang.empty())
diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp
index 5ac6b46..bd6b2ec 100644
--- a/src/insets/InsetRef.cpp
+++ b/src/insets/InsetRef.cpp
@@ -140,8 +140,8 @@ docstring InsetRef::getEscapedLabel(OutputParams const & 
rp) const
 
 void InsetRef::latex(otexstream & os, OutputParams const & rp) const
 {
-       string const cmd = getCmdName();
-       docstring const data = getEscapedLabel(rp);
+       string const & cmd = getCmdName();
+       docstring const & data = getEscapedLabel(rp);
 
        if (rp.inulemcmd > 0)
                os << "\\mbox{";
diff --git a/src/insets/InsetWrap.cpp b/src/insets/InsetWrap.cpp
index 181474a..d86fc25 100644
--- a/src/insets/InsetWrap.cpp
+++ b/src/insets/InsetWrap.cpp
@@ -230,7 +230,7 @@ docstring InsetWrap::xhtml(XHTMLStream & xs, OutputParams 
const & rp) const
        string const len = params_.width.asHTMLString();
        string const width = len.empty() ? "50%" : len;
        InsetLayout const & il = getLayout();
-       string const tag = il.htmltag();
+       string const & tag = il.htmltag();
        string const attr = il.htmlattr() + " style='width:" + width + ";'";
        xs << html::StartTag(tag, attr);
        docstring const deferred = 

Reply via email to