Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: compiler/java/com/google/dart/compiler/util/StringInterner.java

Issue 12571002: Intern AST and Model names to reduce char[]/String waste. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: compiler/java/com/google/dart/compiler/util/StringInterner.java
diff --git a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/html/parser/TestAll.java b/compiler/java/com/google/dart/compiler/util/StringInterner.java
similarity index 61%
copy from editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/html/parser/TestAll.java
copy to compiler/java/com/google/dart/compiler/util/StringInterner.java
index 59291181a3b19caabb2e19e756b35f7a303ff950..e33118e9266818403dc362a5eca75928d273beab 100644
--- a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/html/parser/TestAll.java
+++ b/compiler/java/com/google/dart/compiler/util/StringInterner.java
@@ -11,17 +11,21 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.dart.engine.html.parser;
-import com.google.dart.engine.ExtendedTestSuite;
+package com.google.dart.compiler.util;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import com.google.common.collect.Interner;
+import com.google.common.collect.Interners;
-public class TestAll {
- public static Test suite() {
- TestSuite suite = new ExtendedTestSuite("Tests in " + TestAll.class.getPackage().getName());
- suite.addTestSuite(HtmlParserTest.class);
- return suite;
+public class StringInterner {
+ private static Interner<String> INTERNER = Interners.newStrongInterner();
+
+ public static String intern(String s) {
+ if (s == null) {
+ return null;
+ }
+ s = new String(s);
+ return INTERNER.intern(s);
+// return s;
}
}

Powered by Google App Engine
This is Rietveld 408576698