Skip to content

Commit

Permalink
simplify code in method AbstractAST#compareTo(IExpr)
Browse files Browse the repository at this point in the history
  • Loading branch information
axkr committed Oct 3, 2024
1 parent 84f7c70 commit 41928c3
Showing 1 changed file with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1616,13 +1616,13 @@ public boolean compareAdjacent(BiPredicate<IExpr, IExpr> 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()) {
Expand All @@ -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()) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 41928c3

Please sign in to comment.