ref: b0267b674082eadc432d3e159a800a874c04454d
parent: 4f7abfdb8bb9ab40f6e624a3353a76935a87321e
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Mon Jan 20 22:23:58 EST 2025
compare_ + fl_compare → fl_compare
--- a/equal.c
+++ b/equal.c
@@ -297,7 +297,7 @@
// 'eq' means unordered comparison is sufficient
value_t
-compare_(value_t a, value_t b, bool eq)
+fl_compare(value_t a, value_t b, bool eq)
{
value_t guess = bounded_compare(a, b, BOUNDED_COMPARE_BOUND, eq);
if(guess == FL_nil){
@@ -307,20 +307,6 @@
return guess;
}
-value_t
-fl_compare(value_t a, value_t b)
-{
- return compare_(a, b, 0);
-}
-
-value_t
-fl_equal(value_t a, value_t b)
-{
- if(eq_comparable(a, b))
- return a == b ? FL_t : FL_f;
- return numval(compare_(a, b, 1)) == 0 ? FL_t : FL_f;
-}
-
/*
optimizations:
- use hash updates instead of calling lookup then insert. i.e. get the
@@ -421,7 +407,7 @@
{
if(eq_comparable(a, b))
return a == b;
- return numval(compare_(a, b, 1)) == 0;
+ return numval(fl_compare(a, b, true)) == 0;
}
uintptr_t
--- a/equal.h
+++ b/equal.h
@@ -4,10 +4,8 @@
#define eq_comparable(a, b) (!(((a)|(b))&1))
#define eq_comparablep(a) (!((a)&1)) /* mag: UNUSED? */
-value_t fl_compare(value_t a, value_t b);
-value_t fl_equal(value_t a, value_t b);
int equal_lispvalue(value_t a, value_t b);
uintptr_t hash_lispvalue(value_t a);
-value_t compare_(value_t a, value_t b, bool eq);
+value_t fl_compare(value_t a, value_t b, bool eq);
int numeric_compare(value_t a, value_t b, bool eq, bool eqnans, bool typeerr);
void comparehash_init(void);
--- a/string.c
+++ b/string.c
@@ -364,7 +364,7 @@
type_error("integer", n);
else
num = conv_to_uint64(cp_data(ptr(n)), cp_numtype(ptr(n)));
- if(numval(fl_compare(args[0], fixnum(0))) < 0){
+ if(numval(fl_compare(args[0], fixnum(0), false)) < 0){
num = -num;
neg = 1;
}
--- a/vm.inc
+++ b/vm.inc
@@ -328,7 +328,7 @@
}else{
x = numeric_compare(a, b, false, false, false);
if(x > 1)
- x = numval(fl_compare(a, b));
+ x = numval(fl_compare(a, b, false));
if(x >= 0){
v = FL_f;
break;
@@ -524,7 +524,7 @@
else if(!leafp(FL(stack)[FL(sp)-2]) || !leafp(FL(stack)[FL(sp)-1]))
v = FL_f;
else
- v = compare_(FL(stack)[FL(sp)-2], FL(stack)[FL(sp)-1], 1) == 0 ? FL_t : FL_f;
+ v = fl_compare(FL(stack)[FL(sp)-2], FL(stack)[FL(sp)-1], true) == 0 ? FL_t : FL_f;
FL(stack)[FL(sp)-2] = v;
POPN(1);
NEXT_OP;
@@ -533,7 +533,7 @@
if(FL(stack)[FL(sp)-2] == FL(stack)[FL(sp)-1])
v = FL_t;
else
- v = compare_(FL(stack)[FL(sp)-2], FL(stack)[FL(sp)-1], 1) == 0 ? FL_t : FL_f;
+ v = fl_compare(FL(stack)[FL(sp)-2], FL(stack)[FL(sp)-1], true) == 0 ? FL_t : FL_f;
FL(stack)[FL(sp)-2] = v;
POPN(1);
NEXT_OP;
@@ -687,7 +687,7 @@
NEXT_OP;
OP(OP_COMPARE)
- FL(stack)[FL(sp)-2] = compare_(FL(stack)[FL(sp)-2], FL(stack)[FL(sp)-1], 0);
+ FL(stack)[FL(sp)-2] = fl_compare(FL(stack)[FL(sp)-2], FL(stack)[FL(sp)-1], false);
POPN(1);
NEXT_OP;