@@ -536,10 +536,20 @@ pub fn op_mod(a: &mut Allocator, input: NodePtr, _max_cost: Cost) -> Response {
536
536
537
537
pub fn op_gr ( a : & mut Allocator , input : NodePtr , _max_cost : Cost ) -> Response {
538
538
let [ v0, v1] = get_args :: < 2 > ( a, input, ">" ) ?;
539
- let ( v0, v0_len) = int_atom ( a, v0, ">" ) ?;
540
- let ( v1, v1_len) = int_atom ( a, v1, ">" ) ?;
541
- let cost = GR_BASE_COST + ( v0_len + v1_len) as Cost * GR_COST_PER_BYTE ;
542
- Ok ( Reduction ( cost, if v0 > v1 { a. one ( ) } else { a. nil ( ) } ) )
539
+
540
+ match ( a. small_number ( v0) , a. small_number ( v1) ) {
541
+ ( Some ( lhs) , Some ( rhs) ) => {
542
+ let cost =
543
+ GR_BASE_COST + ( len_for_value ( lhs) + len_for_value ( rhs) ) as Cost * GR_COST_PER_BYTE ;
544
+ Ok ( Reduction ( cost, if lhs > rhs { a. one ( ) } else { a. nil ( ) } ) )
545
+ }
546
+ _ => {
547
+ let ( v0, v0_len) = int_atom ( a, v0, ">" ) ?;
548
+ let ( v1, v1_len) = int_atom ( a, v1, ">" ) ?;
549
+ let cost = GR_BASE_COST + ( v0_len + v1_len) as Cost * GR_COST_PER_BYTE ;
550
+ Ok ( Reduction ( cost, if v0 > v1 { a. one ( ) } else { a. nil ( ) } ) )
551
+ }
552
+ }
543
553
}
544
554
545
555
pub fn op_gr_bytes ( a : & mut Allocator , input : NodePtr , _max_cost : Cost ) -> Response {
0 commit comments