From 41928c30c1394ff3cc6d34d1f6b3192575ed09b1 Mon Sep 17 00:00:00 2001 From: axexlck Date: Thu, 3 Oct 2024 23:48:37 +0200 Subject: [PATCH] simplify code in method `AbstractAST#compareTo(IExpr)` --- .../core/expression/AbstractAST.java | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/expression/AbstractAST.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/expression/AbstractAST.java index d95feaa13..da968f6ee 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/expression/AbstractAST.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/expression/AbstractAST.java @@ -1616,13 +1616,13 @@ public boolean compareAdjacent(BiPredicate predicate) { */ @Override public int compareTo(final IExpr rhsExpr) { + if (rhsExpr.isNumber()) { + // O-7 + return 1; + } final int lhsOrdinal = headID(); int rhsOrdinal = -1; if (lhsOrdinal < 0) { - if (rhsExpr.isNumber()) { - // O-7 - return 1; - } rhsOrdinal = rhsExpr.headID(); if (rhsOrdinal < 0) { if (rhsExpr.isAST()) { @@ -1634,19 +1634,11 @@ public int compareTo(final IExpr rhsExpr) { } } else { if (lhsOrdinal == ID.DirectedInfinity && isDirectedInfinity()) { - if (rhsExpr.isNumber()) { - // O-7 - return 1; - } if (!rhsExpr.isDirectedInfinity()) { return -1; } return compareToASTIncreasing(this, (IAST) rhsExpr); } - if (rhsExpr.isNumber()) { - // O-7 - return 1; - } rhsOrdinal = rhsExpr.headID(); } if (rhsExpr.isAST()) { @@ -5463,7 +5455,7 @@ public IExpr opposite() { } return rest(); } - return setAtCopy(1, ((INumber) arg1).negate()); + return setAtCopy(1, arg1.negate()); } IASTAppendable timesAST = copyAppendable(); timesAST.append(1, F.CN1);