groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwagenleit...@apache.org
Subject [2/2] groovy git commit: cache CALL_TYPES values for read-only access
Date Sat, 08 Jul 2017 19:30:56 GMT
cache CALL_TYPES values for read-only access

Avoid array allocations done by the compiler generated
Enum.values() method.


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

Branch: refs/heads/GROOVY_2_4_X
Commit: 200436c5f15fd1b77ccaa93508fc7091ec51bbcc
Parents: 2f6c231
Author: John Wagenleitner <jwagenleitner@apache.org>
Authored: Sat Jul 8 12:09:47 2017 -0700
Committer: John Wagenleitner <jwagenleitner@apache.org>
Committed: Sat Jul 8 12:29:48 2017 -0700

----------------------------------------------------------------------
 src/main/org/codehaus/groovy/vmplugin/v7/Selector.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/200436c5/src/main/org/codehaus/groovy/vmplugin/v7/Selector.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/vmplugin/v7/Selector.java b/src/main/org/codehaus/groovy/vmplugin/v7/Selector.java
index f5658fc..f1ba892 100644
--- a/src/main/org/codehaus/groovy/vmplugin/v7/Selector.java
+++ b/src/main/org/codehaus/groovy/vmplugin/v7/Selector.java
@@ -88,11 +88,14 @@ public abstract class Selector {
     public boolean catchException = true;
     public CALL_TYPES callType;
 
+    /** Cache values for read-only access */
+    private static final CALL_TYPES[] CALL_TYPES_VALUES = CALL_TYPES.values();
+
     /**
      * Returns the Selector
      */
     public static Selector getSelector(MutableCallSite callSite, Class sender, String methodName,
int callID, boolean safeNavigation, boolean thisCall, boolean spreadCall, Object[] arguments)
{
-        CALL_TYPES callType = CALL_TYPES.values()[callID];
+        CALL_TYPES callType = CALL_TYPES_VALUES[callID];
         switch (callType) {
             case INIT: return new InitSelector(callSite, sender, methodName, callType, safeNavigation,
thisCall, spreadCall, arguments);
             case METHOD: return new MethodSelector(callSite, sender, methodName, callType,
safeNavigation, thisCall, spreadCall, arguments);


Mime
View raw message