From 06df2e2d2991824f253d93a9df30c2b612fd79f4 Mon Sep 17 00:00:00 2001
From: Roberto Raggi <roberto.raggi@nokia.com>
Date: Thu, 11 Nov 2010 14:28:05 +0100
Subject: [PATCH] Use only interned (unique) strings.

---
 src/libs/glsl/glsl.g         |  2 +-
 src/libs/glsl/glslast.h      | 32 ++++++++++++++++----------------
 src/libs/glsl/glslparser.cpp |  2 +-
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/libs/glsl/glsl.g b/src/libs/glsl/glsl.g
index 7d09e2433f8..c35a0eceacf 100644
--- a/src/libs/glsl/glsl.g
+++ b/src/libs/glsl/glsl.g
@@ -460,7 +460,7 @@ switch(ruleno) {
 variable_identifier ::= IDENTIFIER ;
 /.
 case $rule_number: {
-    ast(1) = new IdentifierExpression(*sym(1).string);
+    ast(1) = new IdentifierExpression(sym(1).string);
 }   break;
 ./
 
diff --git a/src/libs/glsl/glslast.h b/src/libs/glsl/glslast.h
index 8f9b3d614c4..4f861533c75 100644
--- a/src/libs/glsl/glslast.h
+++ b/src/libs/glsl/glslast.h
@@ -286,7 +286,7 @@ public:
 class GLSL_EXPORT IdentifierExpression: public Expression
 {
 public:
-    IdentifierExpression(const std::string &_name)
+    IdentifierExpression(const std::string *_name)
         : Expression(Kind_Identifier), name(_name) {}
     ~IdentifierExpression();
 
@@ -295,13 +295,13 @@ public:
     virtual void accept0(Visitor *visitor);
 
 public: // attributes
-    std::string name;
+    const std::string *name;
 };
 
 class GLSL_EXPORT LiteralExpression: public Expression
 {
 public:
-    LiteralExpression(const std::string &_value)
+    LiteralExpression(const std::string *_value)
         : Expression(Kind_Literal), value(_value) {}
     ~LiteralExpression();
 
@@ -310,7 +310,7 @@ public:
     virtual void accept0(Visitor *visitor);
 
 public: // attributes
-    std::string value;
+    const std::string *value;
 };
 
 class GLSL_EXPORT BinaryExpression: public Expression
@@ -380,7 +380,7 @@ public: // attributes
 class GLSL_EXPORT MemberAccessExpression: public Expression
 {
 public:
-    MemberAccessExpression(Expression *_expr, const std::string &_field)
+    MemberAccessExpression(Expression *_expr, const std::string *_field)
         : Expression(Kind_MemberAccess), expr(_expr), field(_field) {}
     ~MemberAccessExpression();
 
@@ -390,15 +390,15 @@ public:
 
 public: // attributes
     Expression *expr;
-    std::string field;
+    const std::string *field;
 };
 
 class GLSL_EXPORT FunctionCallExpression: public Expression
 {
 public:
-    FunctionCallExpression(const std::string &_name)
+    FunctionCallExpression(const std::string *_name)
         : Expression(Kind_FunctionCall), expr(0), name(_name) {}
-    FunctionCallExpression(Expression *_expr, const std::string &_name)
+    FunctionCallExpression(Expression *_expr, const std::string *_name)
         : Expression(Kind_MemberFunctionCall), expr(_expr), name(_name) {}
     ~FunctionCallExpression();
 
@@ -410,7 +410,7 @@ public:
 
 public: // attributes
     Expression *expr;
-    std::string name;
+    const std::string *name;
     std::vector<Expression *> arguments;
 };
 
@@ -632,7 +632,7 @@ public: // attributes
 class GLSL_EXPORT NamedType: public Type
 {
 public:
-    NamedType(const std::string &_name) : Type(Kind_NamedType), name(_name) {}
+    NamedType(const std::string *_name) : Type(Kind_NamedType), name(_name) {}
     ~NamedType();
 
     virtual NamedType *asNamedType() { return this; }
@@ -645,7 +645,7 @@ public:
     virtual Type *clone() const;
 
 public: // attributes
-    std::string name;
+    const std::string *name;
 };
 
 class GLSL_EXPORT ArrayType: public Type
@@ -675,7 +675,7 @@ class GLSL_EXPORT StructType: public Type
 {
 public:
     StructType() : Type(Kind_AnonymousStructType) {}
-    StructType(const std::string &_name)
+    StructType(const std::string *_name)
         : Type(Kind_StructType), name(_name) {}
     ~StructType();
 
@@ -691,13 +691,13 @@ public:
     class Field: public AST
     {
     public:
-        Field(const std::string &_name)
+        Field(const std::string *_name)
             : AST(Kind_StructField), name(_name), type(0) {}
 
         // Takes the outer shell of an array type with the innermost
         // element type set to null.  The fixInnerTypes() method will
         // set the innermost element type to a meaningful value.
-        Field(const std::string &_name, Type *_type)
+        Field(const std::string *_name, Type *_type)
             : AST(Kind_StructField), name(_name), type(_type) {}
 
         ~Field();
@@ -706,7 +706,7 @@ public:
 
         void setInnerType(Type *innerType);
 
-        std::string name;
+        const std::string *name;
         Type *type;
     };
 
@@ -717,7 +717,7 @@ public:
     void addFields(const std::vector<Field *> &list);
 
 public: // attributes
-    std::string name;
+    const std::string *name;
     std::vector<Field *> fields;
 };
 
diff --git a/src/libs/glsl/glslparser.cpp b/src/libs/glsl/glslparser.cpp
index fd9fb26d94d..d3dbd093d79 100644
--- a/src/libs/glsl/glslparser.cpp
+++ b/src/libs/glsl/glslparser.cpp
@@ -167,7 +167,7 @@ switch(ruleno) {
 #line 461 "./glsl.g"
 
 case 0: {
-    ast(1) = new IdentifierExpression(*sym(1).string);
+    ast(1) = new IdentifierExpression(sym(1).string);
 }   break;
 
 #line 468 "./glsl.g"
-- 
GitLab