From b627b8701b6598f5402cbab55a83026c9e3b1e86 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Tue, 24 Feb 2015 10:17:45 +0100 Subject: [PATCH] Some performance stuff reported by cppcheck --- src/Buffer.cpp | 2 +- src/LyX.cpp | 2 +- src/Paragraph.cpp | 4 ++-- src/Text.cpp | 8 ++++---- src/Text2.cpp | 2 +- src/Text3.cpp | 2 +- src/TextMetrics.cpp | 2 +- src/insets/InsetCaption.cpp | 2 +- src/insets/InsetCitation.cpp | 2 +- src/insets/InsetListings.cpp | 2 +- src/insets/InsetRef.cpp | 4 ++-- src/insets/InsetWrap.cpp | 2 +- 12 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index b8e233a781..f6af77d364 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 8b75b44c08..f06b970925 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::iterator dupe = dupes.begin(); dupe != dupes.end(); dupe++) { + for (std::set::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 8ee06ea01f..0570753fa9 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 a2ae1aed8f..a448a5c7ee 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 4f6a975957..2597e35edf 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 e2602f031b..f49274fb4d 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 2119f8ed16..afc7f4ebdc 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 8af9827b3a..ad6ec01d1a 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 8f697993b1..36dc376308 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 const valid_styles) +CitationStyle asValidLatexCommand(string const & input, vector const & valid_styles) { CitationStyle cs = valid_styles[0]; cs.forceUpperCase = false; diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp index e9a89cf520..f6b699b4a8 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 5ac6b46966..bd6b2ecfec 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 181474a889..d86fc25c3d 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 = -- 2.39.5