Calculate TFunction::mangledName lazily.

This saves us ~15KiB per compiler instance on 32-bit Android.

BUG=492725

Change-Id: I9db2998482941b5ab2eb5cb4925cbd1fb58ab4be
Reviewed-on: https://chromium-review.googlesource.com/283584
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/SymbolTable.cpp b/src/compiler/translator/SymbolTable.cpp
index 35887d0..27f5579 100644
--- a/src/compiler/translator/SymbolTable.cpp
+++ b/src/compiler/translator/SymbolTable.cpp
@@ -29,6 +29,18 @@
         delete (*i).type;
 }
 
+const TString *TFunction::buildMangledName() const
+{
+    std::string mangledName = mangleName(getName()).c_str();
+
+    for (const auto &p : parameters)
+    {
+        mangledName += p.type->getMangledName().c_str();
+    }
+
+    return NewPoolTString(mangledName.c_str());
+}
+
 //
 // Symbol table levels are a map of pointers to symbols that have to be deleted.
 //
diff --git a/src/compiler/translator/SymbolTable.h b/src/compiler/translator/SymbolTable.h
index 7f16769..4e3a203 100644
--- a/src/compiler/translator/SymbolTable.h
+++ b/src/compiler/translator/SymbolTable.h
@@ -223,7 +223,7 @@
     TFunction(const TString *name, const TType *retType, TOperator tOp = EOpNull, const char *ext = "")
         : TSymbol(name),
           returnType(retType),
-          mangledName(TFunction::mangleName(*name)),
+          mangledName(nullptr),
           op(tOp),
           defined(false)
     {
@@ -245,14 +245,18 @@
     }
 
     void addParameter(const TConstParameter &p)
-    { 
+    {
         parameters.push_back(p);
-        mangledName = mangledName + p.type->getMangledName();
+        mangledName = nullptr;
     }
 
     const TString &getMangledName() const
     {
-        return mangledName;
+        if (mangledName == nullptr)
+        {
+            mangledName = buildMangledName();
+        }
+        return *mangledName;
     }
     const TType &getReturnType() const
     {
@@ -283,10 +287,12 @@
     }
 
   private:
+    const TString *buildMangledName() const;
+
     typedef TVector<TConstParameter> TParamList;
     TParamList parameters;
     const TType *returnType;
-    TString mangledName;
+    mutable const TString *mangledName;
     TOperator op;
     bool defined;
 };