You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2019/11/21 16:23:24 UTC

[groovy] branch TWEAK-GROOVY-9126 created (now 068f92e)

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a change to branch TWEAK-GROOVY-9126
in repository https://gitbox.apache.org/repos/asf/groovy.git.


      at 068f92e  Tweak GROOVY-9126: Remove unnecessary checks

This branch includes the following new commits:

     new 068f92e  Tweak GROOVY-9126: Remove unnecessary checks

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[groovy] 01/01: Tweak GROOVY-9126: Remove unnecessary checks

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch TWEAK-GROOVY-9126
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 068f92effc36a64df4a1ef86c364f29258337353
Author: Daniel.Sun <su...@apache.org>
AuthorDate: Fri Nov 22 00:23:15 2019 +0800

    Tweak GROOVY-9126: Remove unnecessary checks
---
 .../java/org/codehaus/groovy/classgen/asm/StatementWriter.java    | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/StatementWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/StatementWriter.java
index 8459b89..35c085a 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/StatementWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/StatementWriter.java
@@ -97,7 +97,7 @@ public class StatementWriter {
 
         // GROOVY-7647
         if (block.getLastLineNumber() > 0
-                && !methodOrConstructorsLastReturnStatementExists(block) // GROOVY-9126
+                && !isMethodOrConstructorBlock(block) // GROOVY-9126
         ) {
             MethodVisitor mv = controller.getMethodVisitor();
             Label blockEnd = new Label();
@@ -108,7 +108,7 @@ public class StatementWriter {
         controller.getOperandStack().popDownTo(mark);
     }
 
-    private boolean methodOrConstructorsLastReturnStatementExists(BlockStatement block) {
+    private boolean isMethodOrConstructorBlock(BlockStatement block) {
         MethodNode methodNode = controller.getMethodNode();
         if (null == methodNode) {
             methodNode = controller.getConstructorNode();
@@ -118,9 +118,7 @@ public class StatementWriter {
             return false;
         }
 
-        List<Statement> statementList = block.getStatements();
-        final int size = statementList.size();
-        return size > 0 && statementList.get(size - 1) instanceof ReturnStatement;
+        return true;
     }
 
     public void writeForStatement(ForStatement loop) {