mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-07 12:32:26 +00:00
Use auto const & when possible to avoid copies
In several range-based for loops, implicit copies are made. Remove that when possible, and try to shut converity up otherwise. Fixes issues found by coverity.
This commit is contained in:
parent
35070ecc03
commit
337cc97174
@ -1979,6 +1979,8 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
|
||||
if (!features.runparams().includeall && !included_children_.empty()) {
|
||||
os << "\\includeonly{";
|
||||
bool first = true;
|
||||
// we do not use "auto const &" here, because incfile is modified later
|
||||
// coverity[auto_causes_copy]
|
||||
for (auto incfile : included_children_) {
|
||||
FileName inc = makeAbsPath(incfile, filepath.absFileName());
|
||||
string mangled = DocFileName(changeExtension(inc.absFileName(), ".tex")).
|
||||
|
@ -556,7 +556,7 @@ QString getAlias(QString name) {
|
||||
has_aliases = true;
|
||||
}
|
||||
// check for the following aliases
|
||||
for (auto alias : aliases) {
|
||||
for (auto const & alias : aliases) {
|
||||
if (name.contains(alias.first))
|
||||
name.replace(alias.first, alias.second);
|
||||
}
|
||||
|
@ -159,6 +159,8 @@ set<string> getTexFileList(string const & filename)
|
||||
getVectorFromString(file.fileContents("UTF-8"), from_ascii("\n"));
|
||||
|
||||
// Normalise paths like /foo//bar ==> /foo/bar
|
||||
// No "auto const &" because doc is modified later
|
||||
// coverity[auto_causes_copy]
|
||||
for (auto doc : doclist) {
|
||||
doc = subst(doc, from_ascii("\r"), docstring());
|
||||
while (contains(doc, from_ascii("//")))
|
||||
|
@ -2424,7 +2424,7 @@ void LatexInfo::buildEntries(bool isPatternString)
|
||||
}
|
||||
// Ignore language if there is math somewhere in pattern-string
|
||||
if (isPatternString) {
|
||||
for (auto s: usedText) {
|
||||
for (auto const & s: usedText) {
|
||||
// Remove entries created in previous search runs
|
||||
keys.erase(s);
|
||||
}
|
||||
|
@ -111,13 +111,13 @@ static string const find_python_binary()
|
||||
// but we are trying hard to find a valid python binary
|
||||
vector<string> const path = getEnvPath("PATH");
|
||||
lyxerr << "Looking for python 3.x ...\n";
|
||||
for (auto bin : path) {
|
||||
for (auto const & bin : path) {
|
||||
QString const dir = toqstr(bin);
|
||||
string const localdir = dir.toLocal8Bit().constData();
|
||||
QDir qdir(dir);
|
||||
qdir.setFilter(QDir::Files | QDir::Executable);
|
||||
QStringList list = qdir.entryList(QStringList("python3*"));
|
||||
for (auto bin2 : list) {
|
||||
for (auto const & bin2 : list) {
|
||||
string const binary = "\"" + addName(localdir,
|
||||
bin2.toLocal8Bit().constData()) + "\"";
|
||||
command = python23_call(binary, true);
|
||||
@ -155,13 +155,13 @@ static string const find_python_binary()
|
||||
QString const exeName = "python2*";
|
||||
#endif // _WIN32
|
||||
|
||||
for (auto bin : path) {
|
||||
for (auto const & bin : path) {
|
||||
QString const dir = toqstr(bin);
|
||||
string const localdir = dir.toLocal8Bit().constData();
|
||||
QDir qdir(dir);
|
||||
qdir.setFilter(QDir::Files | QDir::Executable);
|
||||
QStringList list = qdir.entryList(QStringList(exeName));
|
||||
for (auto bin2 : list) {
|
||||
for (auto const & bin2 : list) {
|
||||
string const binary = "\"" + addName(localdir,
|
||||
bin2.toLocal8Bit().constData()) + "\"";
|
||||
command = python23_call(binary, true);
|
||||
|
Loading…
Reference in New Issue
Block a user