Intern strings in the compiler AST to reduce memory footprint.
Review at http://gwt-code-reviews.appspot.com/946801
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@8921 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/jjs/ast/JAnnotation.java b/dev/core/src/com/google/gwt/dev/jjs/ast/JAnnotation.java
index 4133976..44d7ece 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/ast/JAnnotation.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/ast/JAnnotation.java
@@ -16,6 +16,7 @@
package com.google.gwt.dev.jjs.ast;
import com.google.gwt.dev.jjs.SourceInfo;
+import com.google.gwt.dev.util.StringInterner;
import com.google.gwt.dev.util.collect.Lists;
import java.lang.annotation.Annotation;
@@ -44,7 +45,7 @@
public Property(SourceInfo sourceInfo, String name,
List<JAnnotationArgument> values) {
super(sourceInfo);
- this.name = name;
+ this.name = StringInterner.get().intern(name);
this.values = Lists.normalize(values);
}
diff --git a/dev/core/src/com/google/gwt/dev/jjs/ast/JLabel.java b/dev/core/src/com/google/gwt/dev/jjs/ast/JLabel.java
index 40397ef..894eea6 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/ast/JLabel.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/ast/JLabel.java
@@ -16,6 +16,7 @@
package com.google.gwt.dev.jjs.ast;
import com.google.gwt.dev.jjs.SourceInfo;
+import com.google.gwt.dev.util.StringInterner;
/**
* Should we have a JLabelRef also?
@@ -26,7 +27,7 @@
public JLabel(SourceInfo info, String name) {
super(info);
- this.name = name;
+ this.name = StringInterner.get().intern(name);
}
public String getName() {
diff --git a/dev/core/src/com/google/gwt/dev/jjs/ast/JParameter.java b/dev/core/src/com/google/gwt/dev/jjs/ast/JParameter.java
index 02cb31e..7331cf1 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/ast/JParameter.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/ast/JParameter.java
@@ -16,7 +16,6 @@
package com.google.gwt.dev.jjs.ast;
import com.google.gwt.dev.jjs.SourceInfo;
-import com.google.gwt.dev.util.StringInterner;
/**
* Java method parameter definition.
@@ -29,7 +28,7 @@
assert (type != null);
assert (enclosingMethod != null);
- JParameter x = new JParameter(info, StringInterner.get().intern(name), type,
+ JParameter x = new JParameter(info, name, type,
isFinal, isThis, enclosingMethod);
enclosingMethod.addParam(x);
diff --git a/dev/core/src/com/google/gwt/dev/jjs/ast/JPrimitiveType.java b/dev/core/src/com/google/gwt/dev/jjs/ast/JPrimitiveType.java
index 432764e..6e62e0d 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/ast/JPrimitiveType.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/ast/JPrimitiveType.java
@@ -16,6 +16,7 @@
package com.google.gwt.dev.jjs.ast;
import com.google.gwt.dev.jjs.SourceOrigin;
+import com.google.gwt.dev.util.StringInterner;
import com.google.gwt.dev.util.collect.HashMap;
import java.util.Map;
@@ -63,9 +64,9 @@
private JPrimitiveType(String name, String signatureName,
String wrapperTypeName, JLiteral defaultValue) {
super(SourceOrigin.UNKNOWN, name, defaultValue);
- this.signatureName = signatureName;
- this.wrapperTypeName = wrapperTypeName;
- Singletons.map.put(name, this);
+ this.signatureName = StringInterner.get().intern(signatureName);
+ this.wrapperTypeName = StringInterner.get().intern(wrapperTypeName);
+ Singletons.map.put(this.name, this);
}
/**
diff --git a/dev/core/src/com/google/gwt/dev/jjs/ast/JType.java b/dev/core/src/com/google/gwt/dev/jjs/ast/JType.java
index 7391010..f772af7 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/ast/JType.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/ast/JType.java
@@ -16,6 +16,7 @@
package com.google.gwt.dev.jjs.ast;
import com.google.gwt.dev.jjs.SourceInfo;
+import com.google.gwt.dev.util.StringInterner;
/**
* Base class for any types entity.
@@ -27,7 +28,7 @@
public JType(SourceInfo info, String name, JLiteral defaultValue) {
super(info);
- this.name = name;
+ this.name = StringInterner.get().intern(name);
this.defaultValue = defaultValue;
}
diff --git a/dev/core/src/com/google/gwt/dev/jjs/ast/JVariable.java b/dev/core/src/com/google/gwt/dev/jjs/ast/JVariable.java
index 1cb5c06..0928cf8 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/ast/JVariable.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/ast/JVariable.java
@@ -16,6 +16,7 @@
package com.google.gwt.dev.jjs.ast;
import com.google.gwt.dev.jjs.SourceInfo;
+import com.google.gwt.dev.util.StringInterner;
import com.google.gwt.dev.util.collect.Lists;
import java.util.List;
@@ -35,7 +36,7 @@
JVariable(SourceInfo info, String name, JType type, boolean isFinal) {
super(info);
assert type != null;
- this.name = name;
+ this.name = StringInterner.get().intern(name);
this.type = type;
this.isFinal = isFinal;
}