Skip to content

Commit

Permalink
kernel: simplify LtPRec code
Browse files Browse the repository at this point in the history
Since both records are sorted at the start, we know that all values
returned by `GET_RNAM_PREC` are negative. So we can do without `labs`.

In case someone is paranoid, note that `GET_RNAM_PREC` uses `ELM_PLIST`
which has an assertion verifying the given index is positive.
  • Loading branch information
fingolfin committed Nov 24, 2024
1 parent ff53a46 commit 0a21849
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/precord.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,8 +682,8 @@ static Int LtPRec(Obj left, Obj right)
// The sense of this comparison is determined by the rule that
// unbound entries compare less than bound ones
if ( GET_RNAM_PREC(left,i) != GET_RNAM_PREC(right,i) ) {
res = !LT(NAME_RNAM(labs(GET_RNAM_PREC(left, i))),
NAME_RNAM(labs(GET_RNAM_PREC(right, i))));
res = !LT(NAME_RNAM(-GET_RNAM_PREC(left, i)),
NAME_RNAM(-GET_RNAM_PREC(right, i)));

Check warning on line 686 in src/precord.c

View check run for this annotation

Codecov / codecov/patch

src/precord.c#L685-L686

Added lines #L685 - L686 were not covered by tests
break;
}

Expand Down

0 comments on commit 0a21849

Please sign in to comment.