Revert "Use ImmutableString for HLSL texture references"

This reverts commit c13bda8678e86ff75a4acfc94f7a45e58224926d.

Reason for revert: May have broken LibFuzzer and AFL builds:

https://ci.chromium.org/buildbot/chromium.fyi/Afl%20Upload%20Linux%20ASan/7718
https://build.chromium.org/deprecated/chromium.fyi/builders/Libfuzzer%20Upload%20Linux%20ASan/builds/8691

In file included from ../../third_party/angle/src/compiler/translator/TextureFunctionHLSL.cpp:12:
In file included from ../../third_party/angle/src/compiler/translator/TextureFunctionHLSL.h:19:
../../third_party/angle/src/compiler/translator/InfoSink.h:40:16: error: call to function 'operator<<' that is neither visible in the template definition nor found by argument-dependent lookup
        stream << t;
               ^
../../third_party/angle/src/compiler/translator/TextureFunctionHLSL.cpp:111:9: note: in instantiation of function template specialization 'sh::TInfoSinkBase::operator<<<sh::ImmutableString>' requested here
    out << textureReference;
        ^
../../third_party/angle/src/compiler/translator/ImmutableString.h:76:15: note: 'operator<<' should be declared prior to the call site or in namespace 'sh'
std::ostream &operator<<(std::ostream &os, const sh::ImmutableString &str);
              ^
1 error generated.

Bug: chromium:806619

Original change's description:
> Use ImmutableString for HLSL texture references
> 
> This also adds ImmutableStringBuilder class, which can be used to
> build ImmutableStrings in place without extra allocations if the
> maximum length is known in advance.
> 
> BUG=angleproject:2267
> TEST=angle_unittests
> 
> Change-Id: I4dfb78adeb0cffcfad0d25753fb8063466012c92
> Reviewed-on: https://chromium-review.googlesource.com/886362
> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
> Reviewed-by: Jamie Madill <jmadill@chromium.org>

TBR=jmadill@chromium.org,cwallez@chromium.org,oetuaho@nvidia.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: angleproject:2267
Change-Id: I445f5a786f8b16c3f40f28df09d45fcb215a9c88
Reviewed-on: https://chromium-review.googlesource.com/890542
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/TextureFunctionHLSL.cpp b/src/compiler/translator/TextureFunctionHLSL.cpp
index 36898ff..d2b65a6 100644
--- a/src/compiler/translator/TextureFunctionHLSL.cpp
+++ b/src/compiler/translator/TextureFunctionHLSL.cpp
@@ -11,7 +11,6 @@
 
 #include "compiler/translator/TextureFunctionHLSL.h"
 
-#include "compiler/translator/ImmutableStringBuilder.h"
 #include "compiler/translator/UtilsHLSL.h"
 
 namespace sh
@@ -105,8 +104,8 @@
 
 void OutputHLSL4SampleFunctionPrefix(TInfoSinkBase &out,
                                      const TextureFunctionHLSL::TextureFunction &textureFunction,
-                                     const ImmutableString &textureReference,
-                                     const ImmutableString &samplerReference)
+                                     const TString &textureReference,
+                                     const TString &samplerReference)
 {
     out << textureReference;
     if (IsIntegerSampler(textureFunction.sampler) ||
@@ -451,56 +450,37 @@
 void GetTextureReference(TInfoSinkBase &out,
                          const TextureFunctionHLSL::TextureFunction &textureFunction,
                          const ShShaderOutput outputType,
-                         ImmutableString *textureReference,
-                         ImmutableString *samplerReference)
+                         TString *textureReference,
+                         TString *samplerReference)
 {
     if (outputType == SH_HLSL_4_1_OUTPUT)
     {
-        static const ImmutableString kTexturesStr("textures");
-        static const ImmutableString kSamplersStr("samplers");
-        static const ImmutableString kSamplerIndexStr("[samplerIndex]");
-        static const ImmutableString kTextureIndexStr("[textureIndex]");
-        static const ImmutableString kSamplerArrayIndexStr("[samplerArrayIndex]");
-        ImmutableString suffix(TextureGroupSuffix(textureFunction.sampler));
-
+        TString suffix = TextureGroupSuffix(textureFunction.sampler);
         if (TextureGroup(textureFunction.sampler) == HLSL_TEXTURE_2D)
         {
-            ImmutableStringBuilder textureRefBuilder(kTexturesStr.length() + suffix.length() +
-                                                     kSamplerIndexStr.length());
-            textureRefBuilder << kTexturesStr << suffix << kSamplerIndexStr;
-            *textureReference = textureRefBuilder;
-            ImmutableStringBuilder samplerRefBuilder(kSamplersStr.length() + suffix.length() +
-                                                     kSamplerIndexStr.length());
-            samplerRefBuilder << kSamplersStr << suffix << kSamplerIndexStr;
-            *samplerReference = samplerRefBuilder;
+            *textureReference = TString("textures") + suffix + "[samplerIndex]";
+            *samplerReference = TString("samplers") + suffix + "[samplerIndex]";
         }
         else
         {
-            out << "    const uint textureIndex = samplerIndex - textureIndexOffset"
-                << suffix.data() << ";\n";
-            ImmutableStringBuilder textureRefBuilder(kTexturesStr.length() + suffix.length() +
-                                                     kTextureIndexStr.length());
-            textureRefBuilder << kTexturesStr << suffix << kTextureIndexStr;
-            *textureReference = textureRefBuilder;
-
-            out << "    const uint samplerArrayIndex = samplerIndex - samplerIndexOffset"
-                << suffix.data() << ";\n";
-            ImmutableStringBuilder samplerRefBuilder(kSamplersStr.length() + suffix.length() +
-                                                     kSamplerArrayIndexStr.length());
-            samplerRefBuilder << kSamplersStr << suffix << kSamplerArrayIndexStr;
-            *samplerReference = samplerRefBuilder;
+            out << "    const uint textureIndex = samplerIndex - textureIndexOffset" << suffix
+                << ";\n";
+            *textureReference = TString("textures") + suffix + "[textureIndex]";
+            out << "    const uint samplerArrayIndex = samplerIndex - samplerIndexOffset" << suffix
+                << ";\n";
+            *samplerReference = TString("samplers") + suffix + "[samplerArrayIndex]";
         }
     }
     else
     {
-        *textureReference = ImmutableString("x");
-        *samplerReference = ImmutableString("s");
+        *textureReference = "x";
+        *samplerReference = "s";
     }
 }
 
 void OutputTextureSizeFunctionBody(TInfoSinkBase &out,
                                    const TextureFunctionHLSL::TextureFunction &textureFunction,
-                                   const ImmutableString &textureReference,
+                                   const TString &textureReference,
                                    bool getDimensionsIgnoresBaseLevel)
 {
     if (IsSampler2DMS(textureFunction.sampler))
@@ -585,7 +565,7 @@
     TInfoSinkBase &out,
     const TextureFunctionHLSL::TextureFunction &textureFunction,
     const ShShaderOutput outputType,
-    const ImmutableString &textureReference,
+    const TString &textureReference,
     TString *texCoordX,
     TString *texCoordY,
     TString *texCoordZ)
@@ -831,8 +811,8 @@
     TInfoSinkBase &out,
     const TextureFunctionHLSL::TextureFunction &textureFunction,
     const ShShaderOutput outputType,
-    const ImmutableString &textureReference,
-    const ImmutableString &samplerReference,
+    const TString &textureReference,
+    const TString &samplerReference,
     const TString &texCoordX,
     const TString &texCoordY,
     const TString &texCoordZ)
@@ -1311,8 +1291,8 @@
         // sampling we need to call the function directly on references to the texture and sampler
         // arrays. The bug was found using dEQP-GLES3.functional.shaders.discard*loop_texture*
         // tests.
-        ImmutableString textureReference("");
-        ImmutableString samplerReference("");
+        TString textureReference;
+        TString samplerReference;
         GetTextureReference(out, textureFunction, outputType, &textureReference, &samplerReference);
 
         if (textureFunction.method == TextureFunction::SIZE)