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

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

sonarqubecloud[bot] commented on PR #2795:
URL: https://github.com/apache/groovy/pull/2795#issuecomment-5307719442

   ## [![Quality Gate 
Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png
 'Quality Gate 
Passed')](https://sonarcloud.io/dashboard?id=apache_groovy&pullRequest=2795) 
**Quality Gate passed**  
   Issues  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [0 New 
issues](https://sonarcloud.io/project/issues?id=apache_groovy&pullRequest=2795&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png
 '') [0 Accepted 
issues](https://sonarcloud.io/project/issues?id=apache_groovy&pullRequest=2795&issueStatuses=ACCEPTED)
   
   Measures  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_groovy&pullRequest=2795&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [93.8% Coverage on New 
Code](https://sonarcloud.io/component_measures?id=apache_groovy&pullRequest=2795&metric=new_coverage&view=list)
  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [0.0% Duplication on New 
Code](https://sonarcloud.io/component_measures?id=apache_groovy&pullRequest=2795&metric=new_duplicated_lines_density&view=list)
  
     
   <!

> Optimize the unrelated-default-method scan during class generation
> ------------------------------------------------------------------
>
>                 Key: GROOVY-12264
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12264
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Daniel Sun
>            Priority: Major
>
> {{Verifier}} rejects a type that inherits two unrelated {{default}} methods 
> of the same signature (GROOVY-10381, refined by GROOVY-11560). The scan runs 
> in class generation for every type that lists two or more interfaces.
> Class generation is a large share of compile wall time. The scan must stay 
> cheap on the common path, where there is no conflict.
> h3. Problem
> * Stream / {{flatMap}} allocation on every such type.
> * {{ClassNode.getAllDeclaredMethods()}} on the class and again on every 
> interface. Each call rebuilds a full hierarchy method map and revisits 
> inherited defaults.
> On a wide or deep interface DAG the second point is quadratic in the number 
> of interfaces.
> h3. Approach
> * Walk each interface's own methods ({{getMethods()}}) with loops. 
> {{getAllInterfaces()}} already includes super-interfaces, so each {{default}} 
> is visited once.
> * Build the override-signature set only when two unrelated defaults actually 
> collide, and only from the class plus its superclasses.
> * Avoid the {{Optional}} allocation in {{MethodNode.isDefault()}}.
> Before:
> {code:java}
> Set<String> declared = node.getAllDeclaredMethods().stream()
>         .filter(m -> !m.isDefault())
>         .map(MethodNodeUtils::methodDescriptorWithoutReturnType)
>         .collect(Collectors.toSet());
> node.getAllInterfaces().stream()
>         .flatMap(iface -> iface.getAllDeclaredMethods().stream())
>         .filter(MethodNode::isDefault)
>         .forEach(method -> {
>             // conflict check
>         });
> {code}
> After:
> {code:java}
> for (ClassNode iface : node.getAllInterfaces()) {
>     for (MethodNode method : iface.getMethods()) { // this interface only
>         if (!method.isDefault()) {
>             continue;
>         }
>         // conflict check; collect overrides only on a real collision
>     }
> }
> {code}
> Same conflict rules. No intended behaviour change.



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

Reply via email to