[torque] Prevent unnecessary copies by using const ref.

Bug: v8:8015
Change-Id: I7f63989a897857c2258ec2bee59aed6100bc689e
Reviewed-on: https://chromium-review.googlesource.com/1209346
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Commit-Queue: Florian Sattler <sattlerf@google.com>
Cr-Commit-Position: refs/heads/master@{#55685}
This commit is contained in:
Florian Sattler 2018-09-06 13:58:51 +02:00 committed by Commit Bot
parent 9feef007b1
commit 4f8939f88c
4 changed files with 7 additions and 7 deletions

View File

@ -475,7 +475,7 @@ void DeclarationVisitor::Visit(TryLabelStatement* stmt) {
}
size_t i = 0;
for (auto p : block->parameters.names) {
for (const auto& p : block->parameters.names) {
const Type* type =
declarations()->GetType(block->parameters.types[i]);
if (type->IsConstexpr()) {
@ -531,7 +531,7 @@ void DeclarationVisitor::GenerateHeader(std::string& file_name) {
}
if (declareParameters) {
int index = 0;
for (auto parameter : builtin->parameter_names()) {
for (const auto& parameter : builtin->parameter_names()) {
if (index >= firstParameterIndex) {
new_contents_stream << ", k" << CamelifyString(parameter);
}
@ -619,7 +619,7 @@ bool DeclarationVisitor::MarkVariableModified(const Variable* variable) {
void DeclarationVisitor::DeclareSignature(const Signature& signature) {
auto type_iterator = signature.parameter_types.types.begin();
for (auto name : signature.parameter_names) {
for (const auto& name : signature.parameter_names) {
const Type* t(*type_iterator++);
if (name.size() != 0) {
DeclareParameter(name, t);

View File

@ -13,7 +13,7 @@ namespace torque {
Signature FileVisitor::MakeSignature(const CallableNodeSignature* signature) {
LabelDeclarationVector definition_vector;
for (auto label : signature->labels) {
for (const auto& label : signature->labels) {
LabelDeclaration def = {label.name, GetTypeVector(label.types)};
definition_vector.push_back(def);
}

View File

@ -1595,7 +1595,7 @@ void ImplementationVisitor::GenerateParameter(
void ImplementationVisitor::GenerateParameterList(const NameVector& list,
size_t first) {
for (auto p : list) {
for (const auto& p : list) {
if (first == 0) {
GenerateParameter(p);
} else {
@ -1998,7 +1998,7 @@ void ImplementationVisitor::GenerateLabelGoto(Label* label) {
std::vector<Label*> ImplementationVisitor::LabelsFromIdentifiers(
const std::vector<std::string>& names) {
std::vector<Label*> result;
for (auto name : names) {
for (const auto& name : names) {
result.push_back(declarations()->LookupLabel(name));
}
return result;

View File

@ -255,7 +255,7 @@ bool Signature::HasSameTypesAs(const Signature& other) const {
return false;
}
size_t i = 0;
for (auto l : labels) {
for (const auto& l : labels) {
if (l.types != other.labels[i++].types) {
return false;
}