[ 
https://issues.apache.org/jira/browse/GROOVY-12285?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18107019#comment-18107019
 ] 

ASF GitHub Bot commented on GROOVY-12285:
-----------------------------------------

Copilot commented on code in PR #2823:
URL: https://github.com/apache/groovy/pull/2823#discussion_r3837362550


##########
subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/ChooseBestMethodBench.java:
##########
@@ -0,0 +1,182 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.groovy.perf;
+
+import org.codehaus.groovy.ast.ClassHelper;

Review Comment:
   Unused import `org.codehaus.groovy.ast.ClassHelper`; the file uses 
`ClassHelper` members via static imports only.
   
   This issue also appears on line 26 of the same file.



##########
subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/DgmMethodLookupBench.java:
##########
@@ -0,0 +1,123 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.groovy.perf;
+
+import org.codehaus.groovy.ast.ClassHelper;

Review Comment:
   Unused import `org.codehaus.groovy.ast.ClassHelper`; the class is only 
referenced via static imports in this file.





> STC: index extension methods by name and skip cloning non-generic parameters
> ----------------------------------------------------------------------------
>
>                 Key: GROOVY-12285
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12285
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Daniel Sun
>            Priority: Major
>
> The static type checker resolves DGM (Default Groovy Methods) and other 
> extension methods by walking the receiver hierarchy and collecting methods of 
> a given name. {{ExtensionMethodCache}} stores a flat list per receiver type, 
> so each named lookup scans every method on that type. Receivers such as 
> {{Object}} and {{Collection}} have hundreds of DGM methods, and that scan 
> sits on the compile hot path.
> {{chooseBestMethod}} erases generic parameter types before measuring 
> argument-parameter distance. It currently clones every candidate's parameter 
> array to do so, including methods that have no generic parameters.
> h3. Proposed change
> * When a class loader's extension methods are scanned, index each receiver 
> list by method name so a named lookup is a hash get rather than a linear scan.
> * Clone a candidate's parameter array only when at least one parameter is a 
> generics placeholder or otherwise uses generics.
> * Drop derived indexes together with the loader's method map so they cannot 
> go stale independently.
> {code:java}
> // today
> for (MethodNode node : fromDGM) {
>     if (node.getName().equals(name)) accumulator.add(node);
> }
> // proposed
> accumulator.addAll(EXTENSION_METHOD_CACHE.get(loader, className, name));
> {code}
> h3. Impact
> Compile-time only. Named lookup results and overload selection stay the same. 
> {{MethodNode}} parameter arrays are not mutated.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to