changeset 995:0a0ca0942f1d

generators: more touchups in Paddings, denser padding again.
author shade
date Wed, 03 Sep 2014 00:33:26 +0400
parents 24f2032b147c
children 77a66bcd6775
files jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java jmh-core/src/main/java/org/openjdk/jmh/generators/core/Paddings.java jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java
diffstat 3 files changed, 15 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java	Tue Sep 02 23:58:13 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java	Wed Sep 03 00:33:26 2014 +0400
@@ -514,7 +514,7 @@
         writer.println();
 
         // generate padding
-        Paddings.padding(writer, "p");
+        Paddings.padding(writer);
 
         writer.println(ident(1) + "int startRndMask;");
 
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/Paddings.java	Tue Sep 02 23:58:13 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/Paddings.java	Wed Sep 03 00:33:26 2014 +0400
@@ -26,40 +26,32 @@
 
 import java.io.PrintWriter;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 public class Paddings {
 
-    private static final Map<String, List<String>> PADDING_CACHE = new HashMap<String, List<String>>();
+    private static final List<String> PADDING_CACHE;
 
-    public static void padding(List<String> lines, String suffix) {
-        List<String> ps = PADDING_CACHE.get(suffix);
-        if (ps != null) {
-            lines.addAll(ps);
-            return;
-        }
-
-        List<String> tl = new ArrayList<String>();
+    static {
+        PADDING_CACHE = new ArrayList<String>();
         for (int p = 0; p < 16; p++) {
             StringBuilder sb = new StringBuilder();
             sb.append("    ");
-            sb.append("boolean ").append(suffix).append(String.format("_%03d", p * 16 + 0));
+            sb.append(String.format("boolean p%03d", p * 16 + 0));
             for (int q = 1; q < 16; q++) {
-                sb.append(", ").append(suffix).append(String.format("_%03d", p * 16 + q));
+                sb.append(String.format(", p%03d", p * 16 + q));
             }
             sb.append(";");
-            tl.add(sb.toString());
+            PADDING_CACHE.add(sb.toString());
         }
-        PADDING_CACHE.put(suffix, tl);
-        lines.addAll(tl);
     }
 
-    public static void padding(PrintWriter writer, String suffix) {
-        List<String> ss = new ArrayList<String>();
-        padding(ss, suffix);
-        for (String s : ss) {
+    public static void padding(List<String> lines) {
+        lines.addAll(PADDING_CACHE);
+    }
+
+    public static void padding(PrintWriter writer) {
+        for (String s : PADDING_CACHE) {
             writer.println(s);
         }
     }
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java	Tue Sep 02 23:58:13 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java	Wed Sep 03 00:33:26 2014 +0400
@@ -40,7 +40,6 @@
 
 import java.io.IOException;
 import java.io.PrintWriter;
-import java.io.Writer;
 import java.lang.annotation.Annotation;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -758,7 +757,7 @@
                 pw.println("import " + so.userType + ";");
 
                 pw.println("public class " + so.type + "_B1 extends " + so.userType + " {");
-                Paddings.padding(pw, "b1");
+                Paddings.padding(pw);
                 addSuperCall(pw, so, "_B1");
                 pw.println("}");
 
@@ -813,7 +812,7 @@
                 pw.println("package " + so.packageName + ";");
 
                 pw.println("public class " + so.type + "_B3 extends " + so.type + "_B2 {");
-                Paddings.padding(pw, "b3");
+                Paddings.padding(pw);
                 addSuperCall(pw, so, "_B3");
                 pw.println("}");
                 pw.println("");