You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2021/04/12 09:23:39 UTC

[groovy] 22/25: GROOVY-9649: Minor refactor: remove redundant if clause

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 4d84b6927a14cf719fba154b771f5bbcb597a076
Author: Esko Toivonen <es...@tuni.fi>
AuthorDate: Fri Apr 9 13:21:07 2021 +0300

    GROOVY-9649: Minor refactor: remove redundant if clause
---
 .../org/codehaus/groovy/runtime/ScriptBytecodeAdapter.java   | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/runtime/ScriptBytecodeAdapter.java b/src/main/java/org/codehaus/groovy/runtime/ScriptBytecodeAdapter.java
index fdd593d..9c19475 100644
--- a/src/main/java/org/codehaus/groovy/runtime/ScriptBytecodeAdapter.java
+++ b/src/main/java/org/codehaus/groovy/runtime/ScriptBytecodeAdapter.java
@@ -661,14 +661,10 @@ public class ScriptBytecodeAdapter {
             return new EmptyRange((Comparable) from);
         }
         if (from instanceof Integer && to instanceof Integer) {
-            int ifrom = (Integer) from;
-            int ito = (Integer) to;
-            if ((!exclusiveLeft && !exclusiveRight) || ifrom != ito) {
-                // Currently, empty ranges where from != to, the range is full exclusive (e.g. 0<..<-1) and from and to
-                // have a different sign are constructed as IntRanges. This is because these ranges can still be used to
-                // index into lists.
-                return new IntRange(!exclusiveLeft, !exclusiveRight, ifrom, ito);
-            }
+            // Currently, empty ranges where from != to, the range is full exclusive (e.g. 0<..<-1) and from and to
+            // have a different sign are constructed as IntRanges. This is because t3hese ranges can still be used to
+            // index into lists.
+            return new IntRange(!exclusiveLeft, !exclusiveRight, (Integer) from, (Integer) to);
         }
         if (from instanceof Number && to instanceof Number) {
             return new NumberRange(comparableNumber((Number) from), comparableNumber((Number) to), !exclusiveLeft, !exclusiveRight);