Sort and format.


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@7336 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/SameParameterValueOptimizer.java b/dev/core/src/com/google/gwt/dev/jjs/impl/SameParameterValueOptimizer.java
index 23ecaba..e118238 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/SameParameterValueOptimizer.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/SameParameterValueOptimizer.java
@@ -51,11 +51,11 @@
         parameterValues.put(((JParameterRef) x.getLhs()).getParameter(), null);
       }
     }
-    
+
     @Override
     public void endVisit(JMethodCall x, Context ctx) {
       JMethod method = x.getTarget();
-      
+
       if (x.canBePolymorphic() || rescuedMethods.contains(method)) {
         return;
       }
@@ -112,27 +112,27 @@
         rescuedMethods.add(x);
       } else {
         JMethod staticImpl = program.staticImplFor(x);
-        if (staticImpl != null && 
-            staticImpl.getEnclosingType().getMethods().contains(staticImpl)) {
+        if (staticImpl != null
+            && staticImpl.getEnclosingType().getMethods().contains(staticImpl)) {
           // instance method is still alive.
           rescuedMethods.add(x);
         }
       }
       return true;
     }
-    
+
     private boolean equalLiterals(JValueLiteral l1, JValueLiteral l2) {
       Object v1 = l1.getValueObj();
       Object v2 = l2.getValueObj();
-      
+
       if (v1 == v2) {
         return true;
       }
-      
+
       if (v1 == null || v2 == null) {
         return false;
       }
-      
+
       return v1.equals(v2);
     }
   }
@@ -167,23 +167,22 @@
   /**
    * Parameter values.
    * 
-   * If doesn't contain a parameter, then its value is unknown.
-   * If contains parameter, and value is null - the parameter's value is not the 
-   * same across all calls.
-   * If value is not null - the parameter's value is the same across all calls.
+   * If doesn't contain a parameter, then its value is unknown. If contains
+   * parameter, and value is null - the parameter's value is not the same across
+   * all calls. If value is not null - the parameter's value is the same across
+   * all calls.
    */
-  private Map<JParameter, JValueLiteral> parameterValues = 
-    new IdentityHashMap<JParameter, JValueLiteral>();
+  private Map<JParameter, JValueLiteral> parameterValues = new IdentityHashMap<JParameter, JValueLiteral>();
+
+  private final JProgram program;
 
   /**
-   * These methods should not be tried to optimized due to their polymorphic 
+   * These methods should not be tried to optimized due to their polymorphic
    * nature.
    * 
    * TODO: support polymorphic calls properly.
    */
   private Set<JMethod> rescuedMethods = new HashSet<JMethod>();
-  
-  private final JProgram program;
 
   private SameParameterValueOptimizer(JProgram program) {
     this.program = program;
@@ -200,8 +199,8 @@
       }
       JValueLiteral valueLiteral = parameterValues.get(parameter);
       if (valueLiteral != null) {
-        SubstituteParameterVisitor substituteParameterVisitor = 
-          new SubstituteParameterVisitor(parameter, valueLiteral);
+        SubstituteParameterVisitor substituteParameterVisitor = new SubstituteParameterVisitor(
+            parameter, valueLiteral);
         substituteParameterVisitor.accept(parameter.getEnclosingMethod());
         madeChanges |= substituteParameterVisitor.didChange();
       }
diff --git a/dev/core/test/com/google/gwt/dev/jjs/impl/SameParameterValueOptimizerTest.java b/dev/core/test/com/google/gwt/dev/jjs/impl/SameParameterValueOptimizerTest.java
index 3e69927..231539b 100644
--- a/dev/core/test/com/google/gwt/dev/jjs/impl/SameParameterValueOptimizerTest.java
+++ b/dev/core/test/com/google/gwt/dev/jjs/impl/SameParameterValueOptimizerTest.java
@@ -10,39 +10,6 @@
  * Test for SameParameterValueOptimizer.
  */
 public class SameParameterValueOptimizerTest extends OptimizerTestBase {
-  public void testSameParameter() throws Exception {
-    assertOptimize("foo", "static void foo(int i) { int j = i; }",
-        "foo(1); foo(1);").into(
-        "public static void foo(int i){",
-        "  int j = 1;",
-        "}");
-  }
-
-  public void testDifferentParameter() throws Exception {
-    assertOptimize("foo", "static void foo(int i) { int j = i; }",
-        "foo(1); foo(2);").into(
-        "public static void foo(int i){",
-        "  int j = i;",
-        "}");
-  }
-
-  public void testNonConstParameter() throws Exception {
-    assertOptimize("foo", "static int foo(int i) { return i; }",
-        "foo(foo(1));").into(
-        "public static int foo(int i){",
-        "  return i;",
-        "}");
-  }
-
-  private OptimizationResult assertOptimize(String methodName,  
-      String methodDecl, String codeSnippet) throws UnableToCompleteException {
-    addSnippetClassDecl(methodDecl);
-    JProgram program = compileSnippet("void", codeSnippet);
-    SameParameterValueOptimizer.exec(program);
-    JMethod method = findMethod(program, methodName);
-    return new OptimizationResult(method);
-  }
-  
   private static class OptimizationResult {
     private final JMethod method;
 
@@ -50,7 +17,7 @@
       this.method = method;
     }
 
-    public void into(String...expectedStrings) {
+    public void into(String... expectedStrings) {
       StringBuffer expected = new StringBuffer();
       for (String s : expectedStrings) {
         if (expected.length() != 0) {
@@ -61,4 +28,30 @@
       assertEquals(expected.toString(), method.toSource());
     }
   }
+
+  public void testDifferentParameter() throws Exception {
+    assertOptimize("foo", "static void foo(int i) { int j = i; }",
+        "foo(1); foo(2);").into("public static void foo(int i){",
+        "  int j = i;", "}");
+  }
+
+  public void testNonConstParameter() throws Exception {
+    assertOptimize("foo", "static int foo(int i) { return i; }", "foo(foo(1));").into(
+        "public static int foo(int i){", "  return i;", "}");
+  }
+
+  public void testSameParameter() throws Exception {
+    assertOptimize("foo", "static void foo(int i) { int j = i; }",
+        "foo(1); foo(1);").into("public static void foo(int i){",
+        "  int j = 1;", "}");
+  }
+
+  private OptimizationResult assertOptimize(String methodName,
+      String methodDecl, String codeSnippet) throws UnableToCompleteException {
+    addSnippetClassDecl(methodDecl);
+    JProgram program = compileSnippet("void", codeSnippet);
+    SameParameterValueOptimizer.exec(program);
+    JMethod method = findMethod(program, methodName);
+    return new OptimizationResult(method);
+  }
 }