groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [groovy] 01/03: GROOVY-9078: Inefficiency in MethodNode and ConstructorNode
Date Fri, 12 Apr 2019 00:28:17 GMT
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit fda625f5a5fa63995a8f973e303c872cc26b16d0
Author: Paul King <paulk@asert.com.au>
AuthorDate: Fri Apr 12 10:24:49 2019 +1000

    GROOVY-9078: Inefficiency in MethodNode and ConstructorNode
    
    remove redundant call
---
 .../java/org/codehaus/groovy/ast/ConstructorNode.java    | 16 ++++------------
 src/main/java/org/codehaus/groovy/ast/MethodNode.java    |  2 --
 2 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/ast/ConstructorNode.java b/src/main/java/org/codehaus/groovy/ast/ConstructorNode.java
index 66fbed4..da9a87f 100644
--- a/src/main/java/org/codehaus/groovy/ast/ConstructorNode.java
+++ b/src/main/java/org/codehaus/groovy/ast/ConstructorNode.java
@@ -23,27 +23,19 @@ import org.codehaus.groovy.ast.expr.Expression;
 import org.codehaus.groovy.ast.stmt.ExpressionStatement;
 import org.codehaus.groovy.ast.stmt.Statement;
 
-
 /**
  * Represents a constructor declaration
  */
 public class ConstructorNode extends MethodNode {
-    
+
     public ConstructorNode(int modifiers, Statement code) {
         this(modifiers, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, code);
     }
-    
+
     public ConstructorNode(int modifiers, Parameter[] parameters, ClassNode[] exceptions,
Statement code) {
-        super("<init>",modifiers,ClassHelper.VOID_TYPE,parameters,exceptions,code);
-        
-        // This variable scope is thrown out and replaced with a different one during semantic
analysis.
-        VariableScope scope = new VariableScope();
-        for (int i = 0; i < parameters.length; i++) {
-            scope.putDeclaredVariable(parameters[i]);
-        }
-        this.setVariableScope(scope);
+        super("<init>", modifiers, ClassHelper.VOID_TYPE, parameters, exceptions, code);
     }
-    
+
     public boolean firstStatementIsSpecialConstructorCall() {
         Statement code = getFirstStatement();
         if (!(code instanceof ExpressionStatement)) return false;
diff --git a/src/main/java/org/codehaus/groovy/ast/MethodNode.java b/src/main/java/org/codehaus/groovy/ast/MethodNode.java
index 25e0aca..37e44ee 100644
--- a/src/main/java/org/codehaus/groovy/ast/MethodNode.java
+++ b/src/main/java/org/codehaus/groovy/ast/MethodNode.java
@@ -54,8 +54,6 @@ public class MethodNode extends AnnotatedNode implements Opcodes {
         this.modifiers = modifiers;
         this.code = code;
         setReturnType(returnType);
-        VariableScope scope = new VariableScope();
-        setVariableScope(scope);
         setParameters(parameters);
         this.hasDefault = false;
         this.exceptions = exceptions;


Mime
View raw message