groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] 01/01: Tweak GROOVY-9126: Remove unnecessary checks
Date Thu, 21 Nov 2019 16:23:25 GMT
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 <sunlan@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) {


Mime
View raw message