Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 8D002200CBF for ; Sat, 8 Jul 2017 21:30:59 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 8979616B2F1; Sat, 8 Jul 2017 19:30:59 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D09F316B2F2 for ; Sat, 8 Jul 2017 21:30:58 +0200 (CEST) Received: (qmail 46913 invoked by uid 500); 8 Jul 2017 19:30:58 -0000 Mailing-List: contact commits-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list commits@groovy.apache.org Received: (qmail 46904 invoked by uid 99); 8 Jul 2017 19:30:58 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 08 Jul 2017 19:30:58 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C2152DF97E; Sat, 8 Jul 2017 19:30:55 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jwagenleitner@apache.org To: commits@groovy.apache.org Date: Sat, 08 Jul 2017 19:30:56 -0000 Message-Id: <60e19f703eb842b091b76cb761857bce@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/2] groovy git commit: cache CALL_TYPES values for read-only access archived-at: Sat, 08 Jul 2017 19:30:59 -0000 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 Authored: Sat Jul 8 12:09:47 2017 -0700 Committer: John Wagenleitner 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);