Skip to content

Commit

Permalink
Fix use of auto that causes a copy
Browse files Browse the repository at this point in the history
  • Loading branch information
GilesBathgate committed Jul 26, 2024
1 parent 0ae6ae1 commit d37603b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ QList<Node*> Context::lookupChildren() const
void Context::setVariablesFromArguments()
{
for(auto i=0; i<parameters.size(); ++i) {
auto param=parameters.at(i);
const auto& param=parameters.at(i);
const QString& paramName=param.getName();
Value* paramVal=param.getValue();
bool found=false;
Expand All @@ -147,7 +147,7 @@ void Context::setVariablesFromArguments()
}
}
if(!found&&i<arguments.size()) {
auto arg=arguments.at(i);
const auto& arg=arguments.at(i);
const QString& argName=arg.getName();
Value* argVal=arg.getValue();
if(argVal->isDefined()&&argName.isEmpty()) {
Expand Down Expand Up @@ -266,7 +266,7 @@ Value* Context::matchArgumentIndex(bool allowChar,bool matchLast, int index, con
if(index >= arguments.size())
return matchArgument(allowChar,matchLast,name);

auto arg = arguments.at(index);
const auto& arg = arguments.at(index);
const QString& argName = arg.getName();
if(argName.isEmpty() || match(allowChar,matchLast,argName,name))
return arg.getValue();
Expand Down
10 changes: 5 additions & 5 deletions src/ui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,12 @@ void MainWindow::exportFile(const QString& type)

const QFileInfo fileInfo(currentEditor()->getFileName());

auto ext=QString(".%1").arg(type.toLower());
auto filter=tr("%1 Files (*%2);;All Files (*)").arg(type.toUpper(),ext);
auto suggestedName=fileInfo.completeBaseName().append(ext);
auto suggestedLocation=fileInfo.absoluteDir().filePath(suggestedName);
const auto& ext=QString(".%1").arg(type.toLower());
const auto& filter=tr("%1 Files (*%2);;All Files (*)").arg(type.toUpper(),ext);
const auto& suggestedName=fileInfo.completeBaseName().append(ext);
const auto& suggestedLocation=fileInfo.absoluteDir().filePath(suggestedName);

auto fileName=MainWindow::getSaveFileName(this,tr("Export..."),suggestedLocation,filter,ext);
const auto& fileName=MainWindow::getSaveFileName(this,tr("Export..."),suggestedLocation,filter,ext);
if(fileName.isEmpty())
return;

Expand Down

0 comments on commit d37603b

Please sign in to comment.