changeset 407:d349049dc58b

Yak shaving: common some cons() calls.
author shade
date Tue, 18 Feb 2014 17:32:08 +0400
parents cf0d7432acfd
children 5740a1770694
files jmh-core/src/main/java/org/openjdk/jmh/processor/internal/StateObjectHandler.java
diffstat 1 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/StateObjectHandler.java	Tue Feb 18 16:55:00 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/StateObjectHandler.java	Tue Feb 18 17:32:08 2014 +0400
@@ -378,8 +378,11 @@
     }
 
     public List<String> getStateInitializers() {
+        Collection<StateObject> sos = cons(stateObjects);
+
         List<String> result = new ArrayList<String>();
-        for (StateObject so : cons(stateObjects)) {
+
+        for (StateObject so : sos) {
             if (so.scope != Scope.Benchmark) continue;
 
             result.add("");
@@ -406,7 +409,7 @@
             result.add("}");
         }
 
-        for (StateObject so : cons(stateObjects)) {
+        for (StateObject so : sos) {
             if (so.scope != Scope.Thread) continue;
 
             result.add("");
@@ -429,7 +432,7 @@
             result.add("}");
         }
 
-        for (StateObject so : cons(stateObjects)) {
+        for (StateObject so : sos) {
             if (so.scope != Scope.Group) continue;
 
             result.add("");
@@ -462,20 +465,22 @@
     }
 
     public Collection<String> getStateDestructors(Element method) {
+        Collection<StateObject> sos = cons(args.get(method.getSimpleName().toString()), implicits.values());
+
         List<String> result = new ArrayList<String>();
-        for (StateObject so : cons(args.get(method.getSimpleName().toString()), implicits.values())) {
+        for (StateObject so : sos) {
             if (so.scope != Scope.Benchmark) continue;
             result.add("synchronized(this.getClass()) {");
             result.add("    " + so.fieldIdentifier + " = null;");
             result.add("}");
         }
 
-        for (StateObject so : cons(args.get(method.getSimpleName().toString()), implicits.values())) {
+        for (StateObject so : sos) {
             if (so.scope != Scope.Thread) continue;
             result.add("" + so.fieldIdentifier + " = null;");
         }
 
-        for (StateObject so : cons(args.get(method.getSimpleName().toString()), implicits.values())) {
+        for (StateObject so : sos) {
             if (so.scope != Scope.Group) continue;
             result.add("synchronized(this.getClass()) {");
             result.add("    " + so.fieldIdentifier + "_map.remove(threadControl.group);");