Author: [email protected]
Date: Wed Apr 29 18:23:37 2009
New Revision: 5311

Modified:
    trunk/dev/core/src/com/google/gwt/dev/javac/CompilationState.java
    trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java
    trunk/dev/core/src/com/google/gwt/dev/shell/StandardGeneratorContext.java

Log:
Since the overhead of computing md5s is not large (just 150ms for 2k files  
of
average size of 4kB), this patch makes md5 computation the default,
irrespective of whether -gen is used or not.

Patch by: amitmanjhi
Review by: robertvawter (desk review)



Modified: trunk/dev/core/src/com/google/gwt/dev/javac/CompilationState.java
==============================================================================
--- trunk/dev/core/src/com/google/gwt/dev/javac/CompilationState.java    
(original)
+++ trunk/dev/core/src/com/google/gwt/dev/javac/CompilationState.java   Wed  
Apr 29 18:23:37 2009
@@ -22,6 +22,7 @@
  import com.google.gwt.dev.js.ast.JsProgram;
  import com.google.gwt.dev.resource.Resource;
  import com.google.gwt.dev.resource.ResourceOracle;
+import com.google.gwt.dev.shell.StandardGeneratorContext.Generated;
  import com.google.gwt.dev.util.PerfLogger;

  import java.util.Collection;
@@ -294,7 +295,10 @@
        CompilationUnit graveyardUnit = graveyardUnits.remove(typeName);
        if (graveyardUnit != null) {
          assert graveyardUnit.getState() == State.GRAVEYARD;
-        if (unit.getStrongHash().equals(graveyardUnit.getStrongHash())) {
+        assert unit instanceof Generated;
+        assert graveyardUnit instanceof Generated;
+        if (((Generated) unit).getStrongHash().equals(
+            ((Generated) graveyardUnit).getStrongHash())) {
            usefulGraveyardUnits.put(typeName, graveyardUnit);
          } else {
            // The old unit is invalidated.
@@ -381,8 +385,7 @@
      }

      // Divide resources into changed and unchanged.
-    Set<Resource> unchanged = new HashSet<Resource>(
-        cachedSourceFiles);
+    Set<Resource> unchanged = new HashSet<Resource>(cachedSourceFiles);
      unchanged.retainAll(newSourceFiles);

      Set<Resource> changed = new HashSet<Resource>(newSourceFiles);

Modified: trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java
==============================================================================
--- trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java     
(original)
+++ trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java    Wed  
Apr 29 18:23:37 2009
@@ -378,15 +378,6 @@
    public abstract String getSource();

    /**
-   * Returns the strong hash of the source. The default implementation  
simply
-   * returns the source. Subclasses can override this implementation if  
source
-   * might be overwritten.
-   */
-  public String getStrongHash() {
-    return getSource();
-  }
-
-  /**
     * Returns the fully-qualified name of the top level public type.
     */
    public abstract String getTypeName();

Modified:  
trunk/dev/core/src/com/google/gwt/dev/shell/StandardGeneratorContext.java
==============================================================================
---  
trunk/dev/core/src/com/google/gwt/dev/shell/StandardGeneratorContext.java       
 
(original)
+++  
trunk/dev/core/src/com/google/gwt/dev/shell/StandardGeneratorContext.java       
 
Wed Apr 29 18:23:37 2009
@@ -58,11 +58,16 @@
    /**
     * Extras added to {...@link CompilationUnit}.
     */
-  interface Generated {
+  public static interface Generated {
      void abort();

      void commit();

+    /**
+     * Returns the strong hash of the source.
+     */
+    String getStrongHash();
+
      String getTypeName();
    }

@@ -82,6 +87,8 @@

      private long creationTime;

+    private String strongHash; // cache so that refreshes work correctly
+
      private StringWriter sw;

      private final String typeName;
@@ -123,6 +130,14 @@
      }

      @Override
+    public String getStrongHash() {
+      if (strongHash == null) {
+        strongHash = Util.computeStrongName(Util.getBytes(getSource()));
+      }
+      return strongHash;
+    }
+
+    @Override
      public String getTypeName() {
        return typeName;
      }
@@ -163,7 +178,6 @@
      public void commit() {
        pw.close();
        pw = null;
-      strongHash = Util.computeStrongName(getSource().getBytes());
      }

      @Override
@@ -180,6 +194,9 @@
       */
      @Override
      public String getStrongHash() {
+      if (strongHash == null) {
+        strongHash = Util.computeStrongName(Util.getBytes(getSource()));
+      }
        return strongHash;
      }


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

Reply via email to