Revision: 10162
Author:   scheg...@google.com
Date:     Mon May  9 07:42:14 2011
Log: Calculates result of getSourceName() one time, so reuse because of CU cache.
Prepares SAXParserFActory one time, so avoids expensive ClassLoader lookups.

Review at http://gwt-code-reviews.appspot.com/1438801

Review by: sco...@google.com
http://code.google.com/p/google-web-toolkit/source/detail?r=10162

Modified:
 /trunk/dev/core/src/com/google/gwt/dev/javac/CompiledClass.java
 /trunk/dev/core/test/com/google/gwt/dev/javac/CompiledClassTest.java

=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/javac/CompiledClass.java Thu Apr 28 06:57:23 2011 +++ /trunk/dev/core/src/com/google/gwt/dev/javac/CompiledClass.java Mon May 9 07:42:14 2011
@@ -38,6 +38,7 @@

   private final CompiledClass enclosingClass;
   private final String internalName;
+  private final String sourceName;
   private final boolean isLocal;
   private transient TypeData typeData;
   private CompilationUnit unit;
@@ -65,6 +66,7 @@
       String internalName) {
     this.enclosingClass = enclosingClass;
     this.internalName = StringInterner.get().intern(internalName);
+ this.sourceName = StringInterner.get().intern(InternalName.toSourceName(internalName));
     this.cacheToken = diskCache.writeByteArray(classBytes);
     this.isLocal = isLocal;
   }
@@ -109,7 +111,7 @@
    * Returns the qualified source name, e.g. {@code java.util.Map.Entry}.
    */
   public String getSourceName() {
- return StringInterner.get().intern(InternalName.toSourceName(internalName));
+    return sourceName;
   }

   public TypeData getTypeData() {
=======================================
--- /trunk/dev/core/test/com/google/gwt/dev/javac/CompiledClassTest.java Mon Feb 7 11:36:28 2011 +++ /trunk/dev/core/test/com/google/gwt/dev/javac/CompiledClassTest.java Mon May 9 07:42:14 2011
@@ -26,7 +26,15 @@
   static byte[] dummyByteCode = {
     (byte) 0xDE, (byte) 0xAD, (byte)0xBE, (byte)0xEF
   };
-  static final String DUMMY_NAME = "com.example.DeadBeef";
+  static final String DUMMY_NAME = "com/example/DeadBeef";
+
+  /**
+   * Test for {@link CompiledClass#getSourceName()}.
+   */
+  public void testSourceName() throws Exception {
+ CompiledClass compiledClass = new CompiledClass(dummyByteCode, null, false, DUMMY_NAME);
+    assertEquals("com.example.DeadBeef", compiledClass.getSourceName());
+  }

   public void testCompiledClassSerialization() throws Exception {
CompiledClass writeObject = new CompiledClass(dummyByteCode, null, false, DUMMY_NAME);

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to