mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Fix a bunch of small performance issues spotted by cppcheck
Most of these are about passing const strings parameters as references.
This commit is contained in:
parent
1cdbb94ff5
commit
93a43742a5
@ -653,7 +653,7 @@ BufferParams const & Buffer::masterParams() const
|
||||
// Copy child authors to the params. We need those pointers.
|
||||
AuthorList const & child_authors = params().authors();
|
||||
AuthorList::Authors::const_iterator it = child_authors.begin();
|
||||
for (; it != child_authors.end(); it++)
|
||||
for (; it != child_authors.end(); ++it)
|
||||
mparams.authors().record(*it);
|
||||
return mparams;
|
||||
}
|
||||
@ -3507,7 +3507,7 @@ void Buffer::changeRefsIfUnique(docstring const & from, docstring const & to)
|
||||
}
|
||||
|
||||
|
||||
void Buffer::getSourceCode(odocstream & os, string const format,
|
||||
void Buffer::getSourceCode(odocstream & os, string const & format,
|
||||
pit_type par_begin, pit_type par_end,
|
||||
OutputWhat output, bool master) const
|
||||
{
|
||||
|
@ -594,7 +594,7 @@ public:
|
||||
|
||||
/// get source code (latex/docbook) for some paragraphs, or all paragraphs
|
||||
/// including preamble
|
||||
void getSourceCode(odocstream & os, std::string const format,
|
||||
void getSourceCode(odocstream & os, std::string const & format,
|
||||
pit_type par_begin, pit_type par_end, OutputWhat output,
|
||||
bool master) const;
|
||||
|
||||
|
@ -2280,7 +2280,7 @@ vector<string> BufferParams::backends() const
|
||||
}
|
||||
|
||||
|
||||
OutputParams::FLAVOR BufferParams::getOutputFlavor(string const format) const
|
||||
OutputParams::FLAVOR BufferParams::getOutputFlavor(string const & format) const
|
||||
{
|
||||
string const dformat = (format.empty() || format == "default") ?
|
||||
getDefaultOutputFormat() : format;
|
||||
@ -2362,7 +2362,7 @@ Font const BufferParams::getFont() const
|
||||
}
|
||||
|
||||
|
||||
InsetQuotes::QuoteLanguage BufferParams::getQuoteStyle(string const qs) const
|
||||
InsetQuotes::QuoteLanguage BufferParams::getQuoteStyle(string const & qs) const
|
||||
{
|
||||
return quoteslangtranslator().find(qs);
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ public:
|
||||
std::string getDefaultOutputFormat() const;
|
||||
/// return the output flavor of \p format or the default
|
||||
OutputParams::FLAVOR getOutputFlavor(
|
||||
std::string const format = std::string()) const;
|
||||
std::string const & format = std::string()) const;
|
||||
///
|
||||
bool isExportable(std::string const & format) const;
|
||||
///
|
||||
@ -207,7 +207,7 @@ public:
|
||||
Font const getFont() const;
|
||||
|
||||
/// translate quote style string to enum value
|
||||
InsetQuotes::QuoteLanguage getQuoteStyle(std::string const qs) const;
|
||||
InsetQuotes::QuoteLanguage getQuoteStyle(std::string const & qs) const;
|
||||
|
||||
/* these are for the PaperLayout */
|
||||
/// the papersize
|
||||
|
@ -257,9 +257,9 @@ const char * EncodingException::what() const throw()
|
||||
|
||||
|
||||
CharInfo::CharInfo(
|
||||
docstring const textcommand, docstring const mathcommand,
|
||||
std::string const textpreamble, std::string const mathpreamble,
|
||||
std::string const tipashortcut, unsigned int flags)
|
||||
docstring const & textcommand, docstring const & mathcommand,
|
||||
std::string const & textpreamble, std::string const & mathpreamble,
|
||||
std::string const & tipashortcut, unsigned int flags)
|
||||
: textcommand_(textcommand), mathcommand_(mathcommand),
|
||||
textpreamble_(textpreamble), mathpreamble_(mathpreamble),
|
||||
tipashortcut_(tipashortcut), flags_(flags)
|
||||
@ -380,7 +380,7 @@ pair<docstring, bool> Encoding::latexChar(char_type c) const
|
||||
}
|
||||
|
||||
|
||||
pair<docstring, docstring> Encoding::latexString(docstring const input, bool dryrun) const
|
||||
pair<docstring, docstring> Encoding::latexString(docstring const & input, bool dryrun) const
|
||||
{
|
||||
docstring result;
|
||||
docstring uncodable;
|
||||
|
@ -59,9 +59,9 @@ class CharInfo {
|
||||
public:
|
||||
CharInfo() : flags_(0) {}
|
||||
CharInfo(
|
||||
docstring const textcommand, docstring const mathcommand,
|
||||
std::string const textpreamble, std::string const mathpreamble,
|
||||
std::string const tipashortcut, unsigned int flags);
|
||||
docstring const & textcommand, docstring const & mathcommand,
|
||||
std::string const & textpreamble, std::string const & mathpreamble,
|
||||
std::string const & tipashortcut, unsigned int flags);
|
||||
// we assume that at least one command is nonempty when using unicodesymbols
|
||||
bool isUnicodeSymbol() const { return !textcommand_.empty() || !mathcommand_.empty(); }
|
||||
/// LaTeX command (text mode) for this character
|
||||
@ -164,7 +164,7 @@ public:
|
||||
* \p dryrun specifies whether the string is used within source
|
||||
* preview (which yields a special warning).
|
||||
*/
|
||||
std::pair<docstring, docstring> latexString(docstring const input,
|
||||
std::pair<docstring, docstring> latexString(docstring const & input,
|
||||
bool dryrun = false) const;
|
||||
/// Which LaTeX package handles this encoding?
|
||||
Package package() const { return package_; }
|
||||
|
@ -1015,7 +1015,7 @@ bool completeFilename(string const & ff, DepTable & head)
|
||||
}
|
||||
|
||||
|
||||
int iterateLine(string const token, regex const reg, string const & closing,
|
||||
int iterateLine(string const & token, regex const & reg, string const & closing,
|
||||
int fragment_pos, DepTable & head)
|
||||
{
|
||||
smatch what;
|
||||
|
@ -64,11 +64,11 @@ public:
|
||||
/// language code
|
||||
std::string const & code() const { return code_; }
|
||||
/// set code (needed for rc.spellchecker_alt_lang)
|
||||
void setCode(std::string const c) { code_ = c; }
|
||||
void setCode(std::string const & c) { code_ = c; }
|
||||
/// language variety (needed by aspell checker)
|
||||
std::string const & variety() const { return variety_; }
|
||||
/// set variety (needed for rc.spellchecker_alt_lang)
|
||||
void setVariety(std::string const v) { variety_ = v; }
|
||||
void setVariety(std::string const & v) { variety_ = v; }
|
||||
/// preamble settings after babel was called
|
||||
std::string const & babel_postsettings() const { return babel_postsettings_; }
|
||||
/// preamble settings before babel is called
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
///
|
||||
typedef std::string base_type;
|
||||
///
|
||||
LayoutFileIndex(base_type t) { data_ = t; }
|
||||
LayoutFileIndex(base_type const & t) : data_(t) { }
|
||||
///
|
||||
operator base_type() const { return data_; }
|
||||
///
|
||||
|
@ -243,7 +243,7 @@ string PDFOptions::readToken(Lexer &lex, string const & token)
|
||||
|
||||
|
||||
// check the string from UI
|
||||
string PDFOptions::quoted_options_check(string const str) const
|
||||
string PDFOptions::quoted_options_check(string const & str) const
|
||||
{
|
||||
return subst(str, "\n", "");
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ public:
|
||||
* Returns repaired string. For the time being only newlines
|
||||
* are checked.
|
||||
*/
|
||||
std::string quoted_options_check(std::string const str) const;
|
||||
std::string quoted_options_check(std::string const & str) const;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -36,7 +36,7 @@ using namespace lyx::support;
|
||||
|
||||
namespace {
|
||||
|
||||
string const guiErrorType(string const s)
|
||||
string const guiErrorType(string const & s)
|
||||
{
|
||||
if (s == "docbook")
|
||||
return N_("DocBook");
|
||||
|
@ -1904,7 +1904,7 @@ PrefFileformats::PrefFileformats(GuiPreferences * form)
|
||||
|
||||
namespace {
|
||||
|
||||
string const l10n_shortcut(string const prettyname, string const shortcut)
|
||||
string const l10n_shortcut(string const & prettyname, string const & shortcut)
|
||||
{
|
||||
if (shortcut.empty())
|
||||
return string();
|
||||
|
@ -94,7 +94,7 @@ static size_t crcCheck(docstring const & s)
|
||||
\return true if the content has changed since last call.
|
||||
*/
|
||||
static bool getContent(BufferView const * view, Buffer::OutputWhat output,
|
||||
QString & qstr, string const format, bool force_getcontent,
|
||||
QString & qstr, string const & format, bool force_getcontent,
|
||||
bool master)
|
||||
{
|
||||
// get the *top* level paragraphs that contain the cursor,
|
||||
|
@ -68,7 +68,7 @@ FileName const unique_tex_filename(FileName const & bufferpath)
|
||||
}
|
||||
|
||||
|
||||
lyx::Converter const * setConverter(string const from)
|
||||
lyx::Converter const * setConverter(string const & from)
|
||||
{
|
||||
typedef vector<string> FmtList;
|
||||
typedef lyx::graphics::Cache GCache;
|
||||
|
@ -599,6 +599,7 @@ void InsetExternal::setParams(InsetExternalParams const & p)
|
||||
LASSERT(false, return);
|
||||
break;
|
||||
case PREVIEW_INSTANT: {
|
||||
//FIXME: why is the value below immediately forgotten?
|
||||
RenderMonitoredPreview * preview_ptr = renderer_->asMonitoredPreview();
|
||||
renderer_.reset(new RenderMonitoredPreview(this));
|
||||
preview_ptr = renderer_->asMonitoredPreview();
|
||||
|
@ -262,7 +262,7 @@ string const tostr(Tabular::BoxType const & num)
|
||||
|
||||
|
||||
// I would have liked a fromstr template a lot better. (Lgb)
|
||||
bool string2type(string const str, LyXAlignment & num)
|
||||
bool string2type(string const & str, LyXAlignment & num)
|
||||
{
|
||||
if (str == "none")
|
||||
num = LYX_ALIGN_NONE;
|
||||
@ -282,7 +282,7 @@ bool string2type(string const str, LyXAlignment & num)
|
||||
}
|
||||
|
||||
|
||||
bool string2type(string const str, Tabular::HAlignment & num)
|
||||
bool string2type(string const & str, Tabular::HAlignment & num)
|
||||
{
|
||||
if (str == "left")
|
||||
num = Tabular::LYX_LONGTABULAR_ALIGN_LEFT;
|
||||
@ -296,7 +296,7 @@ bool string2type(string const str, Tabular::HAlignment & num)
|
||||
}
|
||||
|
||||
|
||||
bool string2type(string const str, Tabular::VAlignment & num)
|
||||
bool string2type(string const & str, Tabular::VAlignment & num)
|
||||
{
|
||||
if (str == "top")
|
||||
num = Tabular::LYX_VALIGN_TOP;
|
||||
@ -310,7 +310,7 @@ bool string2type(string const str, Tabular::VAlignment & num)
|
||||
}
|
||||
|
||||
|
||||
bool string2type(string const str, Tabular::BoxType & num)
|
||||
bool string2type(string const & str, Tabular::BoxType & num)
|
||||
{
|
||||
if (str == "none")
|
||||
num = Tabular::BOX_NONE;
|
||||
@ -324,7 +324,7 @@ bool string2type(string const str, Tabular::BoxType & num)
|
||||
}
|
||||
|
||||
|
||||
bool string2type(string const str, bool & num)
|
||||
bool string2type(string const & str, bool & num)
|
||||
{
|
||||
if (str == "true")
|
||||
num = true;
|
||||
@ -534,7 +534,7 @@ DocIterator separatorPos(InsetTableCell * cell, docstring const & align_d)
|
||||
}
|
||||
|
||||
|
||||
InsetTableCell splitCell(InsetTableCell & head, docstring const align_d, bool & hassep)
|
||||
InsetTableCell splitCell(InsetTableCell & head, docstring const & align_d, bool & hassep)
|
||||
{
|
||||
InsetTableCell tail = InsetTableCell(head);
|
||||
DocIterator const dit = separatorPos(&head, align_d);
|
||||
@ -2164,7 +2164,7 @@ bool Tabular::isPartOfMultiRow(row_type row, col_type column) const
|
||||
}
|
||||
|
||||
|
||||
void Tabular::TeXTopHLine(otexstream & os, row_type row, string const lang) const
|
||||
void Tabular::TeXTopHLine(otexstream & os, row_type row, string const & lang) const
|
||||
{
|
||||
// we only output complete row lines and the 1st row here, the rest
|
||||
// is done in Tabular::TeXBottomHLine(...)
|
||||
@ -2226,7 +2226,7 @@ void Tabular::TeXTopHLine(otexstream & os, row_type row, string const lang) cons
|
||||
}
|
||||
|
||||
|
||||
void Tabular::TeXBottomHLine(otexstream & os, row_type row, string const lang) const
|
||||
void Tabular::TeXBottomHLine(otexstream & os, row_type row, string const & lang) const
|
||||
{
|
||||
// we output bottomlines of row r and the toplines of row r+1
|
||||
// if the latter do not span the whole tabular
|
||||
|
@ -770,9 +770,9 @@ public:
|
||||
///
|
||||
// helper function for Latex
|
||||
///
|
||||
void TeXTopHLine(otexstream &, row_type row, std::string const lang) const;
|
||||
void TeXTopHLine(otexstream &, row_type row, std::string const & lang) const;
|
||||
///
|
||||
void TeXBottomHLine(otexstream &, row_type row, std::string const lang) const;
|
||||
void TeXBottomHLine(otexstream &, row_type row, std::string const & lang) const;
|
||||
///
|
||||
void TeXCellPreamble(otexstream &, idx_type cell, bool & ismulticol, bool & ismultirow) const;
|
||||
///
|
||||
@ -1029,7 +1029,7 @@ private:
|
||||
std::string const featureAsString(Tabular::Feature feature);
|
||||
|
||||
/// Split cell on decimal symbol
|
||||
InsetTableCell splitCell(InsetTableCell & head, docstring const decimal_sym, bool & hassep);
|
||||
InsetTableCell splitCell(InsetTableCell & head, docstring const & decimal_sym, bool & hassep);
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
|
@ -1197,7 +1197,7 @@ namespace {
|
||||
istringstream is(out);
|
||||
string line;
|
||||
getline(is, line);
|
||||
if (line.find("on line") != 0)
|
||||
if (!prefixIs(line, "on line"))
|
||||
break; // error message not identified
|
||||
getline(is, line);
|
||||
size_t pos = line.find('^');
|
||||
|
@ -217,7 +217,7 @@ void writePlaintextParagraph(Buffer const & buf,
|
||||
switch (c) {
|
||||
case ' ':
|
||||
os << ' ';
|
||||
currlinelen++;
|
||||
++currlinelen;
|
||||
break;
|
||||
|
||||
case '\0':
|
||||
|
@ -831,7 +831,7 @@ ParagraphList::const_iterator findLastParagraph(
|
||||
|
||||
|
||||
ParagraphList::const_iterator findEndOfEnvironment(
|
||||
ParagraphList::const_iterator const pstart,
|
||||
ParagraphList::const_iterator const & pstart,
|
||||
ParagraphList::const_iterator const & pend)
|
||||
{
|
||||
ParagraphList::const_iterator p = pstart;
|
||||
|
@ -102,7 +102,7 @@ docstring sgml::escapeString(docstring const & raw)
|
||||
}
|
||||
|
||||
|
||||
docstring const sgml::uniqueID(docstring const label)
|
||||
docstring const sgml::uniqueID(docstring const & label)
|
||||
{
|
||||
// FIXME THREAD
|
||||
// It seems unlikely there could be a problem here,
|
||||
|
@ -37,7 +37,7 @@ docstring cleanID(Buffer const & buf, OutputParams const & runparams,
|
||||
docstring const & orig);
|
||||
|
||||
/// returns a unique numeric id
|
||||
docstring const uniqueID(docstring const label);
|
||||
docstring const uniqueID(docstring const & label);
|
||||
|
||||
/// Opens tag
|
||||
void openTag(odocstream & os, std::string const & name,
|
||||
|
@ -205,7 +205,7 @@ typedef map<string, DocumentClassPtr> ModuleMap;
|
||||
ModuleMap modules;
|
||||
|
||||
|
||||
bool addModule(string const module, LayoutFile const & baseClass, LayoutModuleList & m, vector<string> & visited)
|
||||
bool addModule(string const & module, LayoutFile const & baseClass, LayoutModuleList & m, vector<string> & visited)
|
||||
{
|
||||
// avoid endless loop for circular dependency
|
||||
vector<string>::const_iterator const vb = visited.begin();
|
||||
|
Loading…
Reference in New Issue
Block a user