groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject groovy git commit: Minor refactoring
Date Tue, 28 Mar 2017 03:03:56 GMT
Repository: groovy
Updated Branches:
  refs/heads/parrot a1d5b6a2c -> 4fb80a1ce


Minor refactoring


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/4fb80a1c
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/4fb80a1c
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/4fb80a1c

Branch: refs/heads/parrot
Commit: 4fb80a1ceca14e44bcd12231f4946533d7ca03ad
Parents: a1d5b6a
Author: sunlan <sunlan@apache.org>
Authored: Tue Mar 28 11:03:47 2017 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Tue Mar 28 11:03:47 2017 +0800

----------------------------------------------------------------------
 src/main/org/codehaus/groovy/syntax/Types.java | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/4fb80a1c/src/main/org/codehaus/groovy/syntax/Types.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/syntax/Types.java b/src/main/org/codehaus/groovy/syntax/Types.java
index 7265009..5cb6154 100644
--- a/src/main/org/codehaus/groovy/syntax/Types.java
+++ b/src/main/org/codehaus/groovy/syntax/Types.java
@@ -1447,9 +1447,13 @@ public class Types
         addDescription( SWITCH_ENTRIES              , "<valid in a switch body>"  
  );
     }
 
-    public static final Set<Integer> ASSIGNMENT_SET = new HashSet<Integer>(Arrays.asList(EQUAL,
BITWISE_AND_EQUAL, BITWISE_OR_EQUAL, BITWISE_XOR_EQUAL, PLUS_EQUAL, MINUS_EQUAL, MULTIPLY_EQUAL,
DIVIDE_EQUAL, INTDIV_EQUAL, MOD_EQUAL, POWER_EQUAL, LEFT_SHIFT_EQUAL, RIGHT_SHIFT_EQUAL, RIGHT_SHIFT_UNSIGNED_EQUAL,
ELVIS_EQUAL));
+    private static final int[] ASSIGNMENT_TYPES;
+    static {
+        ASSIGNMENT_TYPES = new int[] { EQUAL, BITWISE_AND_EQUAL, BITWISE_OR_EQUAL, BITWISE_XOR_EQUAL,
PLUS_EQUAL, MINUS_EQUAL, MULTIPLY_EQUAL, DIVIDE_EQUAL, INTDIV_EQUAL, MOD_EQUAL, POWER_EQUAL,
LEFT_SHIFT_EQUAL, RIGHT_SHIFT_EQUAL, RIGHT_SHIFT_UNSIGNED_EQUAL, ELVIS_EQUAL };
+        Arrays.sort(ASSIGNMENT_TYPES);
+    }
 
-    public static boolean isAssignment(Integer type) {
-        return ASSIGNMENT_SET.contains(type);
+    public static boolean isAssignment(int type) {
+        return Arrays.binarySearch(ASSIGNMENT_TYPES, type) >= 0;
     }
 }


Mime
View raw message