Clean up unnecessary use of TString

TString was being used in some places where it was not really needed.
Clean these up.

BUG=angleproject:2267
TEST=angle_unittests

Change-Id: Ib7fd26f9c6b6b885433c840a9520393908f1f902
Reviewed-on: https://chromium-review.googlesource.com/887068
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/IntermNode.h b/src/compiler/translator/IntermNode.h
index 067b5de..63be891 100644
--- a/src/compiler/translator/IntermNode.h
+++ b/src/compiler/translator/IntermNode.h
@@ -287,7 +287,7 @@
 class TIntermRaw : public TIntermExpression
 {
   public:
-    TIntermRaw(const TType &type, const TString &rawText)
+    TIntermRaw(const TType &type, const ImmutableString &rawText)
         : TIntermExpression(type), mRawText(rawText)
     {
     }
@@ -301,7 +301,7 @@
 
     bool hasSideEffects() const override { return false; }
 
-    TString getRawText() const { return mRawText; }
+    const ImmutableString &getRawText() const { return mRawText; }
 
     void traverse(TIntermTraverser *it) override;
 
@@ -309,7 +309,7 @@
     bool replaceChildNode(TIntermNode *, TIntermNode *) override { return false; }
 
   protected:
-    TString mRawText;
+    ImmutableString mRawText;
 };
 
 // Constant folded node.
diff --git a/src/compiler/translator/OutputGLSLBase.cpp b/src/compiler/translator/OutputGLSLBase.cpp
index f04127f..74b38d2 100644
--- a/src/compiler/translator/OutputGLSLBase.cpp
+++ b/src/compiler/translator/OutputGLSLBase.cpp
@@ -678,8 +678,8 @@
 
 bool TOutputGLSLBase::visitUnary(Visit visit, TIntermUnary *node)
 {
-    TString preString;
-    TString postString = ")";
+    const char *preString  = "";
+    const char *postString = ")";
 
     switch (node->getOp())
     {
@@ -780,7 +780,7 @@
             UNREACHABLE();
     }
 
-    writeTriplet(visit, preString.c_str(), nullptr, postString.c_str());
+    writeTriplet(visit, preString, nullptr, postString);
 
     return true;
 }
diff --git a/src/compiler/translator/OutputHLSL.cpp b/src/compiler/translator/OutputHLSL.cpp
index faf6591..74c0f8d 100644
--- a/src/compiler/translator/OutputHLSL.cpp
+++ b/src/compiler/translator/OutputHLSL.cpp
@@ -419,7 +419,7 @@
         const ImmutableString &name = varying.second->name();
 
         // Program linking depends on this exact format
-        varyings += "static " + InterpolationString(type.getQualifier()) + " " + TypeString(type) +
+        varyings += TString("static ") + InterpolationString(type.getQualifier()) + " " + TypeString(type) +
                     " " + Decorate(name) + ArrayString(type) + " = " + zeroInitializer(type) +
                     ";\n";
     }
@@ -1776,7 +1776,7 @@
         {
             ensureStructDefined(symbol->getType());
 
-            out << argumentString(symbol);
+            writeParameter(symbol, out);
 
             if (i < parameters->size() - 1)
             {
@@ -1894,7 +1894,7 @@
         TIntermSymbol *symbol = (*arguments)[i]->getAsSymbolNode();
         ASSERT(symbol != nullptr);
 
-        out << argumentString(symbol);
+        writeParameter(symbol, out);
 
         if (i < arguments->size() - 1)
         {
@@ -2642,7 +2642,7 @@
     }
 }
 
-TString OutputHLSL::argumentString(const TIntermSymbol *symbol)
+void OutputHLSL::writeParameter(const TIntermSymbol *symbol, TInfoSinkBase &out)
 {
     TQualifier qualifier = symbol->getQualifier();
     const TType &type    = symbol->getType();
@@ -2665,20 +2665,21 @@
         {
             // Samplers are passed as indices to the sampler array.
             ASSERT(qualifier != EvqOut && qualifier != EvqInOut);
-            return "const uint " + nameStr + ArrayString(type);
+            out << "const uint " << nameStr << ArrayString(type);
+            return;
         }
         if (mOutputType == SH_HLSL_4_0_FL9_3_OUTPUT)
         {
-            return QualifierString(qualifier) + " " + TextureString(type.getBasicType()) +
-                   " texture_" + nameStr + ArrayString(type) + ", " + QualifierString(qualifier) +
-                   " " + SamplerString(type.getBasicType()) + " sampler_" + nameStr +
-                   ArrayString(type);
+            out << QualifierString(qualifier) << " " << TextureString(type.getBasicType())
+                << " texture_" << nameStr << ArrayString(type) << ", " << QualifierString(qualifier)
+                << " " << SamplerString(type.getBasicType()) << " sampler_" << nameStr
+                << ArrayString(type);
+            return;
         }
     }
 
-    TStringStream argString;
-    argString << QualifierString(qualifier) << " " << TypeString(type) << " " << nameStr
-              << ArrayString(type);
+    out << QualifierString(qualifier) << " " << TypeString(type) << " " << nameStr
+        << ArrayString(type);
 
     // If the structure parameter contains samplers, they need to be passed into the function as
     // separate parameters. HLSL doesn't natively support samplers in structs.
@@ -2695,28 +2696,25 @@
             const TType &samplerType = sampler->getType();
             if (mOutputType == SH_HLSL_4_1_OUTPUT)
             {
-                argString << ", const uint " << sampler->name() << ArrayString(samplerType);
+                out << ", const uint " << sampler->name() << ArrayString(samplerType);
             }
             else if (mOutputType == SH_HLSL_4_0_FL9_3_OUTPUT)
             {
                 ASSERT(IsSampler(samplerType.getBasicType()));
-                argString << ", " << QualifierString(qualifier) << " "
-                          << TextureString(samplerType.getBasicType()) << " texture_"
-                          << sampler->name() << ArrayString(samplerType) << ", "
-                          << QualifierString(qualifier) << " "
-                          << SamplerString(samplerType.getBasicType()) << " sampler_"
-                          << sampler->name() << ArrayString(samplerType);
+                out << ", " << QualifierString(qualifier) << " "
+                    << TextureString(samplerType.getBasicType()) << " texture_" << sampler->name()
+                    << ArrayString(samplerType) << ", " << QualifierString(qualifier) << " "
+                    << SamplerString(samplerType.getBasicType()) << " sampler_" << sampler->name()
+                    << ArrayString(samplerType);
             }
             else
             {
                 ASSERT(IsSampler(samplerType.getBasicType()));
-                argString << ", " << QualifierString(qualifier) << " " << TypeString(samplerType)
-                          << " " << sampler->name() << ArrayString(samplerType);
+                out << ", " << QualifierString(qualifier) << " " << TypeString(samplerType) << " "
+                    << sampler->name() << ArrayString(samplerType);
             }
         }
     }
-
-    return argString.str();
 }
 
 TString OutputHLSL::zeroInitializer(const TType &type)
diff --git a/src/compiler/translator/OutputHLSL.h b/src/compiler/translator/OutputHLSL.h
index 8b632a8..c929cd9 100644
--- a/src/compiler/translator/OutputHLSL.h
+++ b/src/compiler/translator/OutputHLSL.h
@@ -112,7 +112,7 @@
                        const char *inString,
                        const char *postString);
     void outputLineDirective(TInfoSinkBase &out, int line);
-    TString argumentString(const TIntermSymbol *symbol);
+    void writeParameter(const TIntermSymbol *symbol, TInfoSinkBase &out);
 
     void outputConstructor(TInfoSinkBase &out, Visit visit, TIntermAggregate *node);
     const TConstantUnion *writeConstantUnion(TInfoSinkBase &out,
diff --git a/src/compiler/translator/UseInterfaceBlockFields.cpp b/src/compiler/translator/UseInterfaceBlockFields.cpp
index df0c2f9..900119d 100644
--- a/src/compiler/translator/UseInterfaceBlockFields.cpp
+++ b/src/compiler/translator/UseInterfaceBlockFields.cpp
@@ -43,7 +43,7 @@
                            TIntermSequence *sequence,
                            const TSymbolTable &symbolTable)
 {
-    ASSERT(var.name.find_last_of('[') == TString::npos);
+    ASSERT(var.name.find_last_of('[') == std::string::npos);
     TIntermSymbol *symbol = ReferenceGlobalVariable(ImmutableString(var.name), symbolTable);
     AddNodeUseStatements(symbol, sequence);
 }
diff --git a/src/compiler/translator/UtilsHLSL.cpp b/src/compiler/translator/UtilsHLSL.cpp
index 88f6d34..b177f2e 100644
--- a/src/compiler/translator/UtilsHLSL.cpp
+++ b/src/compiler/translator/UtilsHLSL.cpp
@@ -15,7 +15,7 @@
 namespace sh
 {
 
-TString SamplerString(const TBasicType type)
+const char *SamplerString(const TBasicType type)
 {
     if (IsShadowSampler(type))
     {
@@ -27,7 +27,7 @@
     }
 }
 
-TString SamplerString(HLSLTextureGroup type)
+const char *SamplerString(HLSLTextureGroup type)
 {
     if (type >= HLSL_COMPARISON_SAMPLER_GROUP_BEGIN && type <= HLSL_COMPARISON_SAMPLER_GROUP_END)
     {
@@ -616,7 +616,7 @@
     return HLSL_RWTEXTURE_UNKNOWN;
 }
 
-TString RWTextureString(const HLSLRWTextureGroup RWTextureGroup)
+const char *RWTextureString(const HLSLRWTextureGroup RWTextureGroup)
 {
     switch (RWTextureGroup)
     {
@@ -657,7 +657,7 @@
     return "<unknown read and write texture type>";
 }
 
-TString RWTextureString(const TBasicType type, TLayoutImageInternalFormat imageInternalFormat)
+const char *RWTextureString(const TBasicType type, TLayoutImageInternalFormat imageInternalFormat)
 {
     return RWTextureString(RWTextureGroup(type, imageInternalFormat));
 }
@@ -974,7 +974,7 @@
     return prefix + StructNameString(structure);
 }
 
-TString InterpolationString(TQualifier qualifier)
+const char *InterpolationString(TQualifier qualifier)
 {
     switch (qualifier)
     {
@@ -1005,7 +1005,7 @@
     return "";
 }
 
-TString QualifierString(TQualifier qualifier)
+const char *QualifierString(TQualifier qualifier)
 {
     switch (qualifier)
     {
diff --git a/src/compiler/translator/UtilsHLSL.h b/src/compiler/translator/UtilsHLSL.h
index 18e678d..d6cb7f9 100644
--- a/src/compiler/translator/UtilsHLSL.h
+++ b/src/compiler/translator/UtilsHLSL.h
@@ -97,16 +97,16 @@
                               TLayoutImageInternalFormat imageInternalFormat = EiifUnspecified);
 HLSLRWTextureGroup RWTextureGroup(const TBasicType type,
                                   TLayoutImageInternalFormat imageInternalFormat);
-TString RWTextureString(const HLSLRWTextureGroup textureGroup);
-TString RWTextureString(const TBasicType type, TLayoutImageInternalFormat imageInternalFormat);
+const char *RWTextureString(const HLSLRWTextureGroup textureGroup);
+const char *RWTextureString(const TBasicType type, TLayoutImageInternalFormat imageInternalFormat);
 const char *RWTextureGroupSuffix(const HLSLRWTextureGroup type);
 const char *RWTextureGroupSuffix(const TBasicType type,
                                  TLayoutImageInternalFormat imageInternalFormat);
 const char *RWTextureTypeSuffix(const TBasicType type,
                                 TLayoutImageInternalFormat imageInternalFormat);
 
-TString SamplerString(const TBasicType type);
-TString SamplerString(HLSLTextureGroup type);
+const char *SamplerString(const TBasicType type);
+const char *SamplerString(HLSLTextureGroup type);
 
 // Adds a prefix to user-defined names to avoid naming clashes.
 TString Decorate(const ImmutableString &string);
@@ -119,8 +119,8 @@
 TString QualifiedStructNameString(const TStructure &structure,
                                   bool useHLSLRowMajorPacking,
                                   bool useStd140Packing);
-TString InterpolationString(TQualifier qualifier);
-TString QualifierString(TQualifier qualifier);
+const char *InterpolationString(TQualifier qualifier);
+const char *QualifierString(TQualifier qualifier);
 // Parameters may need to be included in function names to disambiguate between overloaded
 // functions.
 TString DisambiguateFunctionName(const TIntermSequence *parameters);