groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] 03/04: Trivial refactoring: simplify collection operations
Date Sat, 26 Oct 2019 17:29:53 GMT
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit a3e278019661653537a7c62b2c4ef23e89b7b07c
Author: Daniel Sun <sunlan@apache.org>
AuthorDate: Sun Oct 27 00:52:03 2019 +0800

    Trivial refactoring: simplify collection operations
    
    (cherry picked from commit 053a2a23ff8daeeefada43b7bbe0e981599bd230)
---
 .../groovy/util/concurrentlinkedhashmap/ConcurrentLinkedHashMap.java  | 4 ++--
 src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java      | 2 +-
 src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java  | 2 +-
 .../org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java  | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/groovy/util/concurrentlinkedhashmap/ConcurrentLinkedHashMap.java
b/src/main/java/org/apache/groovy/util/concurrentlinkedhashmap/ConcurrentLinkedHashMap.java
index 8121d91..522b3f6 100644
--- a/src/main/java/org/apache/groovy/util/concurrentlinkedhashmap/ConcurrentLinkedHashMap.java
+++ b/src/main/java/org/apache/groovy/util/concurrentlinkedhashmap/ConcurrentLinkedHashMap.java
@@ -28,6 +28,7 @@ import java.util.AbstractMap;
 import java.util.AbstractQueue;
 import java.util.AbstractSet;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
@@ -44,7 +45,6 @@ import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 import java.util.function.Function;
 
-import static java.util.Collections.emptyList;
 import static java.util.Collections.unmodifiableMap;
 import static java.util.Collections.unmodifiableSet;
 import static org.apache.groovy.util.concurrentlinkedhashmap.ConcurrentLinkedHashMap.DrainStatus.IDLE;
@@ -1506,7 +1506,7 @@ public final class ConcurrentLinkedHashMap<K, V> extends AbstractMap<K,
V>
     @Override public Object poll() { return null; }
     @Override public Object peek() { return null; }
     @Override public int size() { return 0; }
-    @Override public Iterator<Object> iterator() { return emptyList().iterator(); }
+    @Override public Iterator<Object> iterator() { return Collections.emptyIterator();
}
   }
 
   /** A listener that ignores all notifications. */
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java b/src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java
index 3caafad..5686b75 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java
@@ -747,7 +747,7 @@ public class CompileStack implements Opcodes {
         StateStackElement result = null;
         for (ListIterator iter = stateStack.listIterator(stateStack.size()); iter.hasPrevious();)
{
             StateStackElement element = (StateStackElement) iter.previous();
-            if (!element.currentBlockNamedLabels.values().contains(label)) {
+            if (!element.currentBlockNamedLabels.containsValue(label)) {
                 if (isBreakLabel && element.breakLabel != label) {
                     result = element;
                     break;
diff --git a/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java b/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java
index 407085f..265ebbd 100644
--- a/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java
+++ b/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java
@@ -957,7 +957,7 @@ public class CompilerConfiguration {
     }
 
     private void setTargetBytecodeIfValid(String version) {
-        if (JDK_TO_BYTECODE_VERSION_MAP.keySet().contains(version)) {
+        if (JDK_TO_BYTECODE_VERSION_MAP.containsKey(version)) {
             this.targetBytecode = version;
         }
     }
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index 25df94b..6be103c 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -2836,7 +2836,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport
{
         if (typeX != null) {
             expectedType = typeX.getType();
         }
-        if (!entries.keySet().contains(name)) {
+        if (!entries.containsKey(name)) {
             if (required) {
                 addStaticTypeError("required named arg '" + name + "' not found.", expression);
             }


Mime
View raw message