groovy-commits mailing list archives

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

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

commit acd211ef724ec8f53f4e17ac6c43b848504d80b0
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
---
 src/main/org/codehaus/groovy/ast/ConstructorNode.java | 18 ++++--------------
 src/main/org/codehaus/groovy/ast/MethodNode.java      |  2 --
 2 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/src/main/org/codehaus/groovy/ast/ConstructorNode.java b/src/main/org/codehaus/groovy/ast/ConstructorNode.java
index fe7a7da..15139f1 100644
--- a/src/main/org/codehaus/groovy/ast/ConstructorNode.java
+++ b/src/main/org/codehaus/groovy/ast/ConstructorNode.java
@@ -23,29 +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
- * 
- * @author <a href="mailto:james@coredevelopers.net">James Strachan</a>
  */
 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 == null || !(code instanceof ExpressionStatement)) return false;
diff --git a/src/main/org/codehaus/groovy/ast/MethodNode.java b/src/main/org/codehaus/groovy/ast/MethodNode.java
index 1c867c3..f219005 100644
--- a/src/main/org/codehaus/groovy/ast/MethodNode.java
+++ b/src/main/org/codehaus/groovy/ast/MethodNode.java
@@ -57,8 +57,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