mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-03 19:52:30 +00:00
Use < 0 instead of == -1 for comparisons
This commit is contained in:
@@ -1199,14 +1199,14 @@ internal_cmp_mag :: internal_compare_magnitude
|
||||
bool := a < b
|
||||
*/
|
||||
internal_int_less_than :: #force_inline proc(a, b: ^Int) -> (less_than: bool) {
|
||||
return internal_cmp(a, b) == -1
|
||||
return internal_cmp(a, b) < 0
|
||||
}
|
||||
|
||||
/*
|
||||
bool := a < b
|
||||
*/
|
||||
internal_int_less_than_digit :: #force_inline proc(a: ^Int, b: DIGIT) -> (less_than: bool) {
|
||||
return internal_cmp_digit(a, b) == -1
|
||||
return internal_cmp_digit(a, b) < 0
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1214,7 +1214,7 @@ internal_int_less_than_digit :: #force_inline proc(a: ^Int, b: DIGIT) -> (less_t
|
||||
Compares the magnitudes only, ignores the sign.
|
||||
*/
|
||||
internal_int_less_than_abs :: #force_inline proc(a, b: ^Int) -> (less_than: bool) {
|
||||
return internal_cmp_mag(a, b) == -1
|
||||
return internal_cmp_mag(a, b) < 0
|
||||
}
|
||||
|
||||
internal_less_than :: proc {
|
||||
@@ -2933,7 +2933,7 @@ internal_int_zero_unused :: #force_inline proc(dest: ^Int, old_used := -1) {
|
||||
If we don't pass the number of previously used DIGITs, we zero all remaining ones.
|
||||
*/
|
||||
zero_count: int
|
||||
if old_used == -1 {
|
||||
if old_used < 0 {
|
||||
zero_count = len(dest.digit) - dest.used
|
||||
} else {
|
||||
zero_count = old_used - dest.used
|
||||
|
||||
@@ -1207,7 +1207,7 @@ internal_random_prime :: proc(a: ^Int, size_in_bits: int, trials: int, flags :=
|
||||
/*
|
||||
Automatically choose the number of Rabin-Miller trials?
|
||||
*/
|
||||
if trials == -1 {
|
||||
if trials < 0 {
|
||||
trials = number_of_rabin_miller_trials(size_in_bits)
|
||||
}
|
||||
|
||||
|
||||
@@ -1662,7 +1662,7 @@ _private_int_log :: proc(a: ^Int, base: DIGIT, allocator := context.allocator) -
|
||||
defer internal_destroy(bracket_low, bracket_high, bracket_mid, t, bi_base)
|
||||
|
||||
ic := #force_inline internal_cmp(a, base)
|
||||
if ic == -1 || ic == 0 {
|
||||
if ic <= 0 {
|
||||
return 1 if ic == 0 else 0, nil
|
||||
}
|
||||
defer if err != nil {
|
||||
@@ -2492,9 +2492,9 @@ _private_int_exponent_mod :: proc(res, G, X, P: ^Int, redmode: int, allocator :=
|
||||
bitcnt -= 1
|
||||
if bitcnt == 0 {
|
||||
/*
|
||||
If digidx == -1 we are out of digits.
|
||||
If digidx < 0 we are out of digits.
|
||||
*/
|
||||
if digidx == -1 { break }
|
||||
if digidx < 0 { break }
|
||||
|
||||
/*
|
||||
Read next digit and reset the bitcnt.
|
||||
@@ -2748,9 +2748,9 @@ _private_int_exponent_mod_fast :: proc(res, G, X, P: ^Int, redmode: int, allocat
|
||||
bitcnt -= 1
|
||||
if bitcnt == 0 {
|
||||
/*
|
||||
If digidx == -1 we are out of digits so break.
|
||||
If digidx < 0 we are out of digits so break.
|
||||
*/
|
||||
if digidx == -1 { break }
|
||||
if digidx < 0 { break }
|
||||
|
||||
/*
|
||||
Read next digit and reset the bitcnt.
|
||||
|
||||
@@ -593,7 +593,7 @@ int_less_than :: #force_inline proc(a, b: ^Int, allocator := context.allocator)
|
||||
c: int
|
||||
c, err = cmp(a, b)
|
||||
|
||||
return c == -1, err
|
||||
return c < 0, err
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -608,7 +608,7 @@ int_less_than_digit :: #force_inline proc(a: ^Int, b: DIGIT, allocator := contex
|
||||
c: int
|
||||
c, err = cmp(a, b)
|
||||
|
||||
return c == -1, err
|
||||
return c < 0, err
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -624,7 +624,7 @@ int_less_than_abs :: #force_inline proc(a, b: ^Int, allocator := context.allocat
|
||||
c: int
|
||||
c, err = cmp_mag(a, b)
|
||||
|
||||
return c == -1, err
|
||||
return c < 0, err
|
||||
}
|
||||
|
||||
less_than :: proc {
|
||||
|
||||
@@ -110,7 +110,7 @@ int_itoa_raw :: proc(a: ^Int, radix: i8, buffer: []u8, size := int(-1), zero_ter
|
||||
/*
|
||||
We weren't given a size. Let's compute it.
|
||||
*/
|
||||
if size == -1 {
|
||||
if size < 0 {
|
||||
size = radix_size(a, radix, zero_terminate) or_return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user