Some performance stuff reported by cppcheck

This commit is contained in:
Jean-Marc Lasgouttes 2015-02-24 10:17:45 +01:00
parent 3d01021c88
commit b627b8701b
12 changed files with 17 additions and 17 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -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);

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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_;

View File

@ -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;

View File

@ -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())

View File

@ -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{";

View File

@ -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 =