[
https://issues.apache.org/jira/browse/GROOVY-11609?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17943917#comment-17943917
]
ASF GitHub Bot commented on GROOVY-11609:
-----------------------------------------
daniellansun closed pull request #2186: GROOVY-11609: Avoid finding same
variable/class member repeatedly
URL: https://github.com/apache/groovy/pull/2186
> Avoid finding same variable/class member repeatedly
> ---------------------------------------------------
>
> Key: GROOVY-11609
> URL: https://issues.apache.org/jira/browse/GROOVY-11609
> Project: Groovy
> Issue Type: Improvement
> Reporter: Daniel Sun
> Priority: Major
>
> When I debugged GROOVY-4721, I found {{VariableScopeVisitor}} will try to
> find same variable/class member again and again, the finding logic is quite
> complex. Unfortunately, {{VariableScopeVisitor}} is widely used, e.g.
> {{ResolveVisitor}}, {{JavaStubCompilationUnit}} and
> {{TraitASTTransformation}}. So it's better to avoid finding same
> variable/class member repeatedly to gain better performance.
> For example, in the following code, {{a}}, {{i}}, {{j}} will be tried to find
> many times:
> {code}
> class BubbleSort {
> public static void bubbleSort(int[] a) {
> for (int i = 0, n = a.length; i < n - 1; i++) {
> for (int j = 0; j < n - i - 1; j++) {
> if (a[j] > a[j + 1]) {
> int temp = a[j]
> a[j] = a[j + 1]
> a[j + 1] = temp
> }
> }
> }
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)