Commit d4c09dd3 by Jonah Ryan-Davis Committed by Commit Bot

Fix unnecessary copy of for loop variables in ANGLE

Bug: angleproject:3075 Change-Id: I34dd5d4ecded6def5a2b46369277312af0de7c8c Reviewed-on: https://chromium-review.googlesource.com/c/1443572Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jonah Ryan-Davis <jonahr@google.com>
parent 65cd76a7
...@@ -74,7 +74,7 @@ MacroExpander::ScopedMacroReenabler::ScopedMacroReenabler(MacroExpander *expande ...@@ -74,7 +74,7 @@ MacroExpander::ScopedMacroReenabler::ScopedMacroReenabler(MacroExpander *expande
MacroExpander::ScopedMacroReenabler::~ScopedMacroReenabler() MacroExpander::ScopedMacroReenabler::~ScopedMacroReenabler()
{ {
mExpander->mDeferReenablingMacros = false; mExpander->mDeferReenablingMacros = false;
for (auto macro : mExpander->mMacrosToReenable) for (const std::shared_ptr<Macro> &macro : mExpander->mMacrosToReenable)
{ {
// Copying the string here by using substr is a check for use-after-free. It detects // Copying the string here by using substr is a check for use-after-free. It detects
// use-after-free more reliably than just toggling the disabled flag. // use-after-free more reliably than just toggling the disabled flag.
......
...@@ -1095,9 +1095,9 @@ bool TCompiler::checkCallDepth() ...@@ -1095,9 +1095,9 @@ bool TCompiler::checkCallDepth()
for (size_t i = 0; i < mCallDag.size(); i++) for (size_t i = 0; i < mCallDag.size(); i++)
{ {
int depth = 0; int depth = 0;
auto &record = mCallDag.getRecordFromIndex(i); const CallDAG::Record &record = mCallDag.getRecordFromIndex(i);
for (auto &calleeIndex : record.callees) for (const int &calleeIndex : record.callees)
{ {
depth = std::max(depth, depths[calleeIndex] + 1); depth = std::max(depth, depths[calleeIndex] + 1);
} }
...@@ -1122,7 +1122,7 @@ bool TCompiler::checkCallDepth() ...@@ -1122,7 +1122,7 @@ bool TCompiler::checkCallDepth()
<< mCallDag.getRecordFromIndex(currentFunction).node->getFunction()->name(); << mCallDag.getRecordFromIndex(currentFunction).node->getFunction()->name();
int nextFunction = -1; int nextFunction = -1;
for (auto &calleeIndex : mCallDag.getRecordFromIndex(currentFunction).callees) for (const int &calleeIndex : mCallDag.getRecordFromIndex(currentFunction).callees)
{ {
if (depths[calleeIndex] == currentDepth - 1) if (depths[calleeIndex] == currentDepth - 1)
{ {
...@@ -1273,7 +1273,7 @@ void TCompiler::useAllMembersInUnusedStandardAndSharedBlocks(TIntermBlock *root) ...@@ -1273,7 +1273,7 @@ void TCompiler::useAllMembersInUnusedStandardAndSharedBlocks(TIntermBlock *root)
{ {
sh::InterfaceBlockList list; sh::InterfaceBlockList list;
for (auto block : mUniformBlocks) for (const sh::InterfaceBlock &block : mUniformBlocks)
{ {
if (!block.staticUse && if (!block.staticUse &&
(block.layout == sh::BLOCKLAYOUT_STD140 || block.layout == sh::BLOCKLAYOUT_SHARED)) (block.layout == sh::BLOCKLAYOUT_STD140 || block.layout == sh::BLOCKLAYOUT_SHARED))
...@@ -1290,7 +1290,7 @@ void TCompiler::initializeOutputVariables(TIntermBlock *root) ...@@ -1290,7 +1290,7 @@ void TCompiler::initializeOutputVariables(TIntermBlock *root)
InitVariableList list; InitVariableList list;
if (mShaderType == GL_VERTEX_SHADER || mShaderType == GL_GEOMETRY_SHADER_EXT) if (mShaderType == GL_VERTEX_SHADER || mShaderType == GL_GEOMETRY_SHADER_EXT)
{ {
for (auto var : mOutputVaryings) for (const sh::Varying &var : mOutputVaryings)
{ {
list.push_back(var); list.push_back(var);
if (var.name == "gl_Position") if (var.name == "gl_Position")
...@@ -1303,7 +1303,7 @@ void TCompiler::initializeOutputVariables(TIntermBlock *root) ...@@ -1303,7 +1303,7 @@ void TCompiler::initializeOutputVariables(TIntermBlock *root)
else else
{ {
ASSERT(mShaderType == GL_FRAGMENT_SHADER); ASSERT(mShaderType == GL_FRAGMENT_SHADER);
for (auto var : mOutputVariables) for (const sh::OutputVariable &var : mOutputVariables)
{ {
list.push_back(var); list.push_back(var);
} }
......
...@@ -194,7 +194,7 @@ bool IncludeSameArrayElement(const std::set<std::string> &nameSet, const std::st ...@@ -194,7 +194,7 @@ bool IncludeSameArrayElement(const std::set<std::string> &nameSet, const std::st
{ {
std::vector<unsigned int> subscripts; std::vector<unsigned int> subscripts;
std::string baseName = ParseResourceName(name, &subscripts); std::string baseName = ParseResourceName(name, &subscripts);
for (auto nameInSet : nameSet) for (const std::string &nameInSet : nameSet)
{ {
std::vector<unsigned int> arrayIndices; std::vector<unsigned int> arrayIndices;
std::string arrayName = ParseResourceName(nameInSet, &arrayIndices); std::string arrayName = ParseResourceName(nameInSet, &arrayIndices);
...@@ -1449,7 +1449,7 @@ void ProgramState::updateTransformFeedbackStrides() ...@@ -1449,7 +1449,7 @@ void ProgramState::updateTransformFeedbackStrides()
{ {
mTransformFeedbackStrides.resize(1); mTransformFeedbackStrides.resize(1);
size_t totalSize = 0; size_t totalSize = 0;
for (auto &varying : mLinkedTransformFeedbackVaryings) for (const TransformFeedbackVarying &varying : mLinkedTransformFeedbackVaryings)
{ {
totalSize += varying.size() * VariableExternalSize(varying.type); totalSize += varying.size() * VariableExternalSize(varying.type);
} }
...@@ -1460,7 +1460,7 @@ void ProgramState::updateTransformFeedbackStrides() ...@@ -1460,7 +1460,7 @@ void ProgramState::updateTransformFeedbackStrides()
mTransformFeedbackStrides.resize(mLinkedTransformFeedbackVaryings.size()); mTransformFeedbackStrides.resize(mLinkedTransformFeedbackVaryings.size());
for (size_t i = 0; i < mLinkedTransformFeedbackVaryings.size(); i++) for (size_t i = 0; i < mLinkedTransformFeedbackVaryings.size(); i++)
{ {
auto &varying = mLinkedTransformFeedbackVaryings[i]; TransformFeedbackVarying &varying = mLinkedTransformFeedbackVaryings[i];
mTransformFeedbackStrides[i] = mTransformFeedbackStrides[i] =
static_cast<GLsizei>(varying.size() * VariableExternalSize(varying.type)); static_cast<GLsizei>(varying.size() * VariableExternalSize(varying.type));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment