mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Follow some of the performance advice from cppcheck
Most of that is changing string to string const &.
This commit is contained in:
parent
94896166d4
commit
714113655a
@ -223,7 +223,7 @@ name_parts nameParts(docstring const & iname)
|
||||
}
|
||||
|
||||
|
||||
docstring constructName(docstring const & name, string const scheme)
|
||||
docstring constructName(docstring const & name, string const & scheme)
|
||||
{
|
||||
// re-constructs a name from name parts according
|
||||
// to a given scheme
|
||||
@ -313,7 +313,7 @@ vector<docstring> const getAuthors(docstring const & author)
|
||||
}
|
||||
|
||||
|
||||
bool multipleAuthors(docstring const author)
|
||||
bool multipleAuthors(docstring const & author)
|
||||
{
|
||||
return getAuthors(author).size() > 1;
|
||||
}
|
||||
|
@ -3583,7 +3583,7 @@ typename M::const_iterator greatest_below(M & m, typename M::key_type const & x)
|
||||
if (it == m.begin())
|
||||
return m.end();
|
||||
|
||||
it--;
|
||||
--it;
|
||||
return it;
|
||||
}
|
||||
|
||||
|
@ -2935,7 +2935,7 @@ void BufferParams::readIncludeonly(Lexer & lex)
|
||||
}
|
||||
|
||||
|
||||
string BufferParams::paperSizeName(PapersizePurpose purpose, string const psize) const
|
||||
string BufferParams::paperSizeName(PapersizePurpose purpose, string const & psize) const
|
||||
{
|
||||
PAPER_SIZE ppsize = psize.empty() ? papersize : papersizetranslator().find(psize);
|
||||
switch (ppsize) {
|
||||
|
@ -467,7 +467,7 @@ public:
|
||||
};
|
||||
///
|
||||
std::string paperSizeName(PapersizePurpose purpose,
|
||||
std::string const psize = std::string()) const;
|
||||
std::string const & psize = std::string()) const;
|
||||
/// set up if and how babel is called
|
||||
std::string babelCall(std::string const & lang_opts, bool const langoptions) const;
|
||||
/// return supported drivers for specific packages
|
||||
|
@ -169,7 +169,7 @@ public:
|
||||
/// set savenote environment (footnote package)
|
||||
std::string saveNoteEnv() const { return savenote_env_; }
|
||||
/// return savenote environment
|
||||
void saveNoteEnv(std::string const s) { savenote_env_ = s; }
|
||||
void saveNoteEnv(std::string const & s) { savenote_env_ = s; }
|
||||
/// Runparams that will be used for exporting this file.
|
||||
OutputParams const & runparams() const { return runparams_; }
|
||||
/// Resolve alternatives like "esint|amsmath|wasysym"
|
||||
|
@ -243,7 +243,7 @@ string const LaTeXFont::getAvailablePackage(bool dryrun)
|
||||
|
||||
|
||||
string const LaTeXFont::getPackageOptions(bool ot1, bool complete, bool sc, bool osf,
|
||||
int scale, string const extraopts, bool nomath)
|
||||
int scale, string const & extraopts, bool nomath)
|
||||
{
|
||||
ostringstream os;
|
||||
bool const needosfopt = (osf != osfdefault_);
|
||||
@ -290,7 +290,7 @@ string const LaTeXFont::getPackageOptions(bool ot1, bool complete, bool sc, bool
|
||||
|
||||
|
||||
string const LaTeXFont::getLaTeXCode(bool dryrun, bool ot1, bool complete, bool sc,
|
||||
bool osf, bool nomath, string const extraopts,
|
||||
bool osf, bool nomath, string const & extraopts,
|
||||
int const & scale)
|
||||
{
|
||||
ostringstream os;
|
||||
|
@ -84,7 +84,7 @@ public:
|
||||
/// Return the LaTeX Code
|
||||
std::string const getLaTeXCode(bool dryrun, bool ot1, bool complete,
|
||||
bool sc, bool osf, bool nomath,
|
||||
std::string const extraopts = std::string(),
|
||||
std::string const & extraopts = std::string(),
|
||||
int const & scale = 100);
|
||||
/// Return the actually used font
|
||||
docstring const getUsedFont(bool ot1, bool complete, bool nomath);
|
||||
@ -103,7 +103,7 @@ private:
|
||||
bool sc,
|
||||
bool osf,
|
||||
int scale,
|
||||
std::string const extraopts,
|
||||
std::string const & extraopts,
|
||||
bool nomath);
|
||||
/// Return an alternative font
|
||||
LaTeXFont altFont(docstring const & name);
|
||||
|
@ -24,7 +24,7 @@ namespace lyx {
|
||||
class PersonalWordList {
|
||||
public:
|
||||
/// the word list has an associated language
|
||||
PersonalWordList(std::string lang) : lang_(lang), dirty_(false) {}
|
||||
PersonalWordList(std::string & lang) : lang_(lang), dirty_(false) {}
|
||||
/// the location of the file to hold to word list
|
||||
lyx::support::FileName dictfile() const;
|
||||
/// (re)load the word list from file
|
||||
|
@ -260,7 +260,7 @@ public:
|
||||
settings are given to the new one.
|
||||
This function will handle a multi-paragraph selection.
|
||||
*/
|
||||
void setParagraphs(Cursor & cur, docstring arg, bool modify = false);
|
||||
void setParagraphs(Cursor & cur, docstring const & arg, bool modify = false);
|
||||
/// Sets parameters for current or selected paragraphs
|
||||
void setParagraphs(Cursor & cur, ParagraphParameters const & p);
|
||||
|
||||
|
@ -483,7 +483,7 @@ void Text::setLabelWidthStringToSequence(Cursor const & cur,
|
||||
}
|
||||
|
||||
|
||||
void Text::setParagraphs(Cursor & cur, docstring arg, bool merge)
|
||||
void Text::setParagraphs(Cursor & cur, docstring const & arg, bool merge)
|
||||
{
|
||||
LBUFERR(cur.text());
|
||||
|
||||
|
@ -43,7 +43,7 @@ namespace lyx {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TocItem::TocItem(DocIterator const & dit, int d, docstring const & s,
|
||||
bool output_active, FuncRequest action)
|
||||
bool output_active, FuncRequest const & action)
|
||||
: dit_(dit), depth_(d), str_(s), output_(output_active),
|
||||
action_(action)
|
||||
{
|
||||
|
@ -61,7 +61,7 @@ public:
|
||||
int depth,
|
||||
docstring const & s,
|
||||
bool output_active,
|
||||
FuncRequest action = FuncRequest(LFUN_UNKNOWN_ACTION)
|
||||
FuncRequest const & action = FuncRequest(LFUN_UNKNOWN_ACTION)
|
||||
);
|
||||
///
|
||||
DocIterator const & dit() const { return dit_; }
|
||||
@ -74,7 +74,7 @@ public:
|
||||
///
|
||||
bool isOutput() const { return output_; }
|
||||
///
|
||||
void setAction(FuncRequest a) { action_ = a; }
|
||||
void setAction(FuncRequest const & a) { action_ = a; }
|
||||
|
||||
/// custom action, or the default one (paragraph-goto) if not customised
|
||||
FuncRequest action() const;
|
||||
|
24
src/Undo.cpp
24
src/Undo.cpp
@ -90,21 +90,15 @@ struct UndoElement
|
||||
{
|
||||
}
|
||||
///
|
||||
UndoElement(UndoElement const & ue) : time(current_time())
|
||||
{
|
||||
kind = ue.kind;
|
||||
cur_before = ue.cur_before;
|
||||
cur_after = ue.cur_after;
|
||||
cell = ue.cell;
|
||||
from = ue.from;
|
||||
end = ue.end;
|
||||
pars = ue.pars;
|
||||
array = ue.array;
|
||||
bparams = ue.bparams
|
||||
? new BufferParams(*ue.bparams) : 0;
|
||||
lyx_clean = ue.lyx_clean;
|
||||
group_id = ue.group_id;
|
||||
}
|
||||
UndoElement(UndoElement const & ue) :
|
||||
kind(ue.kind),
|
||||
cur_before(ue.cur_before), cur_after(ue.cur_after),
|
||||
cell(ue.cell), from(ue.from), end(ue.end),
|
||||
pars(ue.pars), array(ue.array),
|
||||
bparams(ue.bparams ? new BufferParams(*ue.bparams) : 0),
|
||||
lyx_clean(ue.lyx_clean), group_id(ue.group_id),
|
||||
time(current_time())
|
||||
{}
|
||||
///
|
||||
~UndoElement()
|
||||
{
|
||||
|
@ -132,7 +132,7 @@ bool InsetBibtex::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
}
|
||||
|
||||
|
||||
void InsetBibtex::editDatabases(docstring const db) const
|
||||
void InsetBibtex::editDatabases(docstring const & db) const
|
||||
{
|
||||
vector<docstring> bibfilelist = getVectorFromString(getParam("bibfiles"));
|
||||
|
||||
|
@ -82,7 +82,7 @@ public:
|
||||
|
||||
private:
|
||||
///
|
||||
void editDatabases(docstring const db = docstring()) const;
|
||||
void editDatabases(docstring const & db = docstring()) const;
|
||||
///
|
||||
void parseBibTeXFiles(support::FileNameList &) const;
|
||||
///
|
||||
|
@ -329,7 +329,7 @@ inline docstring wrapCitation(docstring const & key,
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
vector<pair<docstring, docstring>> InsetCitation::getQualifiedLists(docstring const p) const
|
||||
vector<pair<docstring, docstring>> InsetCitation::getQualifiedLists(docstring const & p) const
|
||||
{
|
||||
vector<docstring> ps =
|
||||
getVectorFromString(p, from_ascii("\t"));
|
||||
|
@ -91,7 +91,7 @@ public:
|
||||
CitationStyle getCitationStyle(BufferParams const & bp, std::string const & input,
|
||||
std::vector<CitationStyle> const & valid_styles) const;
|
||||
///
|
||||
QualifiedList getQualifiedLists(docstring const p) const;
|
||||
QualifiedList getQualifiedLists(docstring const & p) const;
|
||||
///
|
||||
static bool last_literal;
|
||||
|
||||
|
@ -588,9 +588,9 @@ docstring const InsetQuotesParams::getGuiLabel(QuoteStyle const & qs, bool langd
|
||||
}
|
||||
|
||||
|
||||
docstring const InsetQuotesParams::getShortGuiLabel(docstring const string)
|
||||
docstring const InsetQuotesParams::getShortGuiLabel(docstring const & str)
|
||||
{
|
||||
std::string const s = to_ascii(string);
|
||||
string const s = to_ascii(str);
|
||||
QuoteStyle const style = getQuoteStyle(s);
|
||||
QuoteSide const side = getQuoteSide(s);
|
||||
QuoteLevel const level = getQuoteLevel(s);
|
||||
|
@ -86,7 +86,7 @@ public:
|
||||
docstring const getGuiLabel(QuoteStyle const & qs,
|
||||
bool langdef = false);
|
||||
/// Returns a descriptive label of a given char
|
||||
docstring const getShortGuiLabel(docstring const string);
|
||||
docstring const getShortGuiLabel(docstring const & str);
|
||||
///
|
||||
int stylescount() const;
|
||||
/// Returns the matching style shortcut char
|
||||
|
@ -93,7 +93,7 @@ class IgnoreFormats {
|
||||
///
|
||||
bool getLanguage() { return ignoreLanguage_; };
|
||||
///
|
||||
void setIgnoreFormat(string type, bool value);
|
||||
void setIgnoreFormat(string const & type, bool value);
|
||||
|
||||
private:
|
||||
///
|
||||
@ -119,7 +119,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
void IgnoreFormats::setIgnoreFormat(string type, bool value)
|
||||
void IgnoreFormats::setIgnoreFormat(string const & type, bool value)
|
||||
{
|
||||
if (type == "color") {
|
||||
ignoreColor_ = value;
|
||||
@ -160,7 +160,7 @@ void IgnoreFormats::setIgnoreFormat(string type, bool value)
|
||||
IgnoreFormats ignoreFormats;
|
||||
|
||||
|
||||
void setIgnoreFormat(string type, bool value)
|
||||
void setIgnoreFormat(string const & type, bool value)
|
||||
{
|
||||
ignoreFormats.setIgnoreFormat(type, value);
|
||||
}
|
||||
@ -1478,7 +1478,8 @@ class LatexInfo {
|
||||
void removeHead(KeyInfo&, int count=0);
|
||||
|
||||
public:
|
||||
LatexInfo(string par, bool isPatternString) : entidx_(-1), interval_(isPatternString, par)
|
||||
LatexInfo(string const & par, bool isPatternString)
|
||||
: entidx_(-1), interval_(isPatternString, par)
|
||||
{
|
||||
buildKeys(isPatternString);
|
||||
entries_ = vector<KeyInfo>();
|
||||
@ -1588,7 +1589,7 @@ class MathInfo {
|
||||
MathInfo() {
|
||||
actualIdx_ = 0;
|
||||
}
|
||||
void insert(string wait, size_t start, size_t end) {
|
||||
void insert(string const & wait, size_t start, size_t end) {
|
||||
MathEntry m = MathEntry();
|
||||
m.wait = wait;
|
||||
m.mathStart = start;
|
||||
|
@ -120,7 +120,7 @@ public:
|
||||
};
|
||||
|
||||
/// Set the formats that should be ignored
|
||||
void setIgnoreFormat(std::string type, bool value);
|
||||
void setIgnoreFormat(std::string const & type, bool value);
|
||||
|
||||
/// Write a FindAdvOptions instance to a stringstream
|
||||
std::ostringstream & operator<<(std::ostringstream & os, lyx::FindAndReplaceOptions const & opt);
|
||||
@ -143,9 +143,6 @@ docstring stringifyFromForSearch(
|
||||
DocIterator const & cur,
|
||||
int len = -1);
|
||||
|
||||
/** Set format type to be ignore by search
|
||||
**/
|
||||
void setIgnoreFormat(std::string type, bool value);
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
|
@ -296,7 +296,7 @@ private:
|
||||
class MTag {
|
||||
public:
|
||||
///
|
||||
MTag(char const * const tag, std::string attr = "")
|
||||
MTag(char const * const tag, std::string const & attr = std::string())
|
||||
: tag_(tag), attr_(attr) {}
|
||||
///
|
||||
char const * const tag_;
|
||||
|
@ -75,7 +75,7 @@ struct StartTag
|
||||
struct EndTag
|
||||
{
|
||||
///
|
||||
explicit EndTag(std::string tag) : tag_(tag) {}
|
||||
explicit EndTag(std::string const & tag) : tag_(tag) {}
|
||||
///
|
||||
virtual ~EndTag() {}
|
||||
/// </tag_>
|
||||
|
@ -32,9 +32,7 @@ public:
|
||||
typedef typename container_type::const_iterator const_iterator;
|
||||
|
||||
/// limit is the maximum size of the stack
|
||||
limited_stack(size_type limit = 100) {
|
||||
limit_ = limit;
|
||||
}
|
||||
limited_stack(size_type limit = 100) : limit_(limit) {}
|
||||
|
||||
/// Return the top element.
|
||||
value_type & top() {
|
||||
|
Loading…
Reference in New Issue
Block a user