clang-tidy: Fix unnecessary copy of for loop variables in ANGLE
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Jan 2019 21:47:51 +0000 (21:47 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Jan 2019 21:47:51 +0000 (21:47 +0000)
<https://webkit.org/b/193443>

Reviewed by Alex Christensen.

Fix unwanted copying of loop variables by making them const
references.

* src/compiler/preprocessor/MacroExpander.cpp:
(pp::MacroExpander::ScopedMacroReenabler::~ScopedMacroReenabler):
- Prevents copy and reference churn of std::shared_ptr<Macro>
  objects.
* src/compiler/translator/Compiler.cpp:
(sh::TCompiler::useAllMembersInUnusedStandardAndSharedBlocks):
- Prevents copy of sh::InterfaceBlock structs.
(sh::TCompiler::initializeOutputVariables):
- Prevents copy of sh::Varying structs.
* src/libANGLE/Program.cpp:
(gl::(anonymous namespace)::IncludeSameArrayElement):
- Prevents copy of std::string objects.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240001 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/ThirdParty/ANGLE/ChangeLog
Source/ThirdParty/ANGLE/src/compiler/preprocessor/MacroExpander.cpp
Source/ThirdParty/ANGLE/src/compiler/translator/Compiler.cpp
Source/ThirdParty/ANGLE/src/libANGLE/Program.cpp

index 5b856e3..fc26c96 100644 (file)
@@ -1,3 +1,26 @@
+2019-01-15  David Kilzer  <ddkilzer@apple.com>
+
+        clang-tidy: Fix unnecessary copy of for loop variables in ANGLE
+        <https://webkit.org/b/193443>
+
+        Reviewed by Alex Christensen.
+
+        Fix unwanted copying of loop variables by making them const
+        references.
+
+        * src/compiler/preprocessor/MacroExpander.cpp:
+        (pp::MacroExpander::ScopedMacroReenabler::~ScopedMacroReenabler):
+        - Prevents copy and reference churn of std::shared_ptr<Macro>
+          objects.
+        * src/compiler/translator/Compiler.cpp:
+        (sh::TCompiler::useAllMembersInUnusedStandardAndSharedBlocks):
+        - Prevents copy of sh::InterfaceBlock structs.
+        (sh::TCompiler::initializeOutputVariables):
+        - Prevents copy of sh::Varying structs.
+        * src/libANGLE/Program.cpp:
+        (gl::(anonymous namespace)::IncludeSameArrayElement):
+        - Prevents copy of std::string objects.
+
 2018-10-03  Dan Bernstein  <mitz@apple.com>
 
         ANGLE part of [Xcode] Update some build settings as recommended by Xcode 10
index d88d3a6..6e2accf 100644 (file)
@@ -70,7 +70,7 @@ MacroExpander::ScopedMacroReenabler::ScopedMacroReenabler(MacroExpander *expande
 MacroExpander::ScopedMacroReenabler::~ScopedMacroReenabler()
 {
     mExpander->mDeferReenablingMacros = false;
-    for (auto macro : mExpander->mMacrosToReenable)
+    for (const auto& macro : mExpander->mMacrosToReenable)
     {
         // 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.
index 2f411cb..594147d 100644 (file)
@@ -1067,7 +1067,7 @@ void TCompiler::useAllMembersInUnusedStandardAndSharedBlocks(TIntermBlock *root)
 {
     sh::InterfaceBlockList list;
 
-    for (auto block : uniformBlocks)
+    for (const auto& block : uniformBlocks)
     {
         if (!block.staticUse &&
             (block.layout == sh::BLOCKLAYOUT_STD140 || block.layout == sh::BLOCKLAYOUT_SHARED))
@@ -1084,7 +1084,7 @@ void TCompiler::initializeOutputVariables(TIntermBlock *root)
     InitVariableList list;
     if (shaderType == GL_VERTEX_SHADER || shaderType == GL_GEOMETRY_SHADER_OES)
     {
-        for (auto var : outputVaryings)
+        for (const auto& var : outputVaryings)
         {
             list.push_back(var);
             if (var.name == "gl_Position")
@@ -1097,7 +1097,7 @@ void TCompiler::initializeOutputVariables(TIntermBlock *root)
     else
     {
         ASSERT(shaderType == GL_FRAGMENT_SHADER);
-        for (auto var : outputVariables)
+        for (const auto& var : outputVariables)
         {
             list.push_back(var);
         }
index 795d326..9cb7fb7 100644 (file)
@@ -192,7 +192,7 @@ bool IncludeSameArrayElement(const std::set<std::string> &nameSet, const std::st
 {
     std::vector<unsigned int> subscripts;
     std::string baseName = ParseResourceName(name, &subscripts);
-    for (auto nameInSet : nameSet)
+    for (const auto& nameInSet : nameSet)
     {
         std::vector<unsigned int> arrayIndices;
         std::string arrayName = ParseResourceName(nameInSet, &arrayIndices);