groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] 01/02: Remove redundant fields and reduce the visibility of lazy nodes
Date Mon, 23 Dec 2019 00:38:43 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 70a8620f90a2a5700cf9b35555550a3c190ba499
Author: Daniel.Sun <realbluesun@hotmail.com>
AuthorDate: Mon Dec 23 08:03:29 2019 +0800

    Remove redundant fields and reduce the visibility of lazy nodes
    
    (cherry picked from commit 0820faeba736a376194cd9a80835f8d6813026f9)
---
 .../org/codehaus/groovy/ast/decompiled/LazyConstructorNode.java    | 7 ++-----
 .../java/org/codehaus/groovy/ast/decompiled/LazyFieldNode.java     | 7 ++-----
 .../java/org/codehaus/groovy/ast/decompiled/LazyMethodNode.java    | 7 ++-----
 3 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/ast/decompiled/LazyConstructorNode.java b/src/main/java/org/codehaus/groovy/ast/decompiled/LazyConstructorNode.java
index 62418ce..459d82a 100644
--- a/src/main/java/org/codehaus/groovy/ast/decompiled/LazyConstructorNode.java
+++ b/src/main/java/org/codehaus/groovy/ast/decompiled/LazyConstructorNode.java
@@ -38,23 +38,20 @@ import java.util.Map;
  *
  * @since 2.5.9
  */
-public class LazyConstructorNode extends ConstructorNode {
+class LazyConstructorNode extends ConstructorNode {
     private final Supplier<ConstructorNode> constructorNodeSupplier;
     private ConstructorNode delegate;
-    private boolean initialized;
 
     public LazyConstructorNode(Supplier<ConstructorNode> constructorNodeSupplier) {
         this.constructorNodeSupplier = constructorNodeSupplier;
     }
 
     private void init() {
-        if (initialized) return;
+        if (null != delegate) return;
         delegate = constructorNodeSupplier.get();
 
         ClassNode declaringClass = super.getDeclaringClass();
         if (null != declaringClass) delegate.setDeclaringClass(declaringClass);
-
-        initialized = true;
     }
 
     @Override
diff --git a/src/main/java/org/codehaus/groovy/ast/decompiled/LazyFieldNode.java b/src/main/java/org/codehaus/groovy/ast/decompiled/LazyFieldNode.java
index d279c14..cc57106 100644
--- a/src/main/java/org/codehaus/groovy/ast/decompiled/LazyFieldNode.java
+++ b/src/main/java/org/codehaus/groovy/ast/decompiled/LazyFieldNode.java
@@ -35,10 +35,9 @@ import java.util.Map;
  *
  * @since 2.5.9
  */
-public class LazyFieldNode extends FieldNode {
+class LazyFieldNode extends FieldNode {
     private final Supplier<FieldNode> fieldNodeSupplier;
     private FieldNode delegate;
-    private boolean initialized;
 
     private String name;
 
@@ -48,7 +47,7 @@ public class LazyFieldNode extends FieldNode {
     }
 
     private void init() {
-        if (initialized) return;
+        if (null != delegate) return;
         delegate = fieldNodeSupplier.get();
 
         ClassNode declaringClass = super.getDeclaringClass();
@@ -56,8 +55,6 @@ public class LazyFieldNode extends FieldNode {
 
         ClassNode owner = super.getOwner();
         if (null != owner) delegate.setOwner(owner);
-
-        initialized = true;
     }
 
     @Override
diff --git a/src/main/java/org/codehaus/groovy/ast/decompiled/LazyMethodNode.java b/src/main/java/org/codehaus/groovy/ast/decompiled/LazyMethodNode.java
index 1da3e94..c25813f 100644
--- a/src/main/java/org/codehaus/groovy/ast/decompiled/LazyMethodNode.java
+++ b/src/main/java/org/codehaus/groovy/ast/decompiled/LazyMethodNode.java
@@ -38,10 +38,9 @@ import java.util.Map;
  *
  * @since 2.5.9
  */
-public class LazyMethodNode extends MethodNode {
+class LazyMethodNode extends MethodNode {
     private final Supplier<MethodNode> methodNodeSupplier;
     private MethodNode delegate;
-    private boolean initialized;
 
     private String name;
 
@@ -51,13 +50,11 @@ public class LazyMethodNode extends MethodNode {
     }
 
     private void init() {
-        if (initialized) return;
+        if (null != delegate) return;
         delegate = methodNodeSupplier.get();
 
         ClassNode declaringClass = super.getDeclaringClass();
         if (null != declaringClass) delegate.setDeclaringClass(declaringClass);
-
-        initialized = true;
     }
 
     @Override


Mime
View raw message