diff options
| author | Xotchkass <78706300+Xotchkass@users.noreply.github.com> | 2025-11-28 14:11:37 +0200 |
|---|---|---|
| committer | Xotchkass <78706300+Xotchkass@users.noreply.github.com> | 2025-11-28 14:11:37 +0200 |
| commit | b8f8e6a8df8f191b423910bd8b89cc9a2679ee4c (patch) | |
| tree | da127439c0ba6bcc051b476f95d786d32475c922 /core | |
| parent | a234f25fa5247df32ecb7eeba3b3bcf4fbfef75f (diff) | |
changed panic to assert
Diffstat (limited to 'core')
| -rw-r--r-- | core/math/rand/rand.odin | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/core/math/rand/rand.odin b/core/math/rand/rand.odin index cc84ee1fc..a9870b9f7 100644 --- a/core/math/rand/rand.odin +++ b/core/math/rand/rand.odin @@ -546,9 +546,7 @@ Possible Output: */ uint32_range :: proc(lo, hi: u32, gen := context.random_generator) -> (val: u32) { - if lo >= hi { - panic("Invalid arguments to uint32_range: lo must be less than hi") - } + assert(lo < hi, "Invalid arguments to uint32_range: lo must be less than hi") range := hi - lo if (range & (range - 1)) == 0 { return lo + (uint32(gen) & (range - 1)) @@ -588,9 +586,7 @@ Possible Output: */ uint64_range :: proc(lo, hi: u64, gen := context.random_generator) -> (val: u64) { - if lo >= hi { - panic("Invalid arguments to uint64_range: lo must be less than hi") - } + assert(lo < hi, "Invalid arguments to uint64_range: lo must be less than hi") range := hi - lo if (range & (range - 1)) == 0 { return lo + (uint64(gen) & (range - 1)) @@ -630,9 +626,7 @@ Possible Output: */ uint128_range :: proc(lo, hi: u128, gen := context.random_generator) -> (val: u128) { - if lo >= hi { - panic("Invalid arguments to uint128_range: lo must be less than hi") - } + assert(lo < hi, "Invalid arguments to uint128_range: lo must be less than hi") range := hi - lo if (range & (range - 1)) == 0 { return lo + (uint128(gen) & (range - 1)) @@ -673,9 +667,7 @@ Possible Output: */ @(require_results) uint_range :: proc(lo, hi: uint, gen := context.random_generator) -> (val: uint) { - if lo >= hi { - panic("Invalid arguments to uint_range: lo must be less than hi") - } + assert(lo < hi, "Invalid arguments to uint_range: lo must be less than hi") when size_of(int) == 4 { return uint(uint32_range(u32(lo), u32(hi), gen)) } else { @@ -710,9 +702,7 @@ Possible Output: */ int32_range :: proc(lo, hi: i32, gen := context.random_generator) -> (val: i32) { - if lo >= hi { - panic("Invalid arguments to int32_range: lo must be less than hi") - } + assert(lo < hi, "Invalid arguments to int32_range: lo must be less than hi") range := u32(hi) - u32(lo) if (range & (range - 1)) == 0 { return lo + i32(uint32(gen) & (range - 1)) @@ -752,9 +742,7 @@ Possible Output: */ int64_range :: proc(lo, hi: i64, gen := context.random_generator) -> (val: i64) { - if lo >= hi { - panic("Invalid arguments to int64_range: lo must be less than hi") - } + assert(lo < hi, "Invalid arguments to int64_range: lo must be less than hi") range := u64(hi) - u64(lo) if (range & (range - 1)) == 0 { return lo + i64(uint64(gen) & (range - 1)) @@ -794,9 +782,7 @@ Possible Output: */ int128_range :: proc(lo, hi: i128, gen := context.random_generator) -> (val: i128) { - if lo >= hi { - panic("Invalid arguments to int128_range: lo must be less than hi") - } + assert(lo < hi, "Invalid arguments to int128_range: lo must be less than hi") range := u128(hi) - u128(lo) if (range & (range - 1)) == 0 { return lo + i128(uint128(gen) & (range - 1)) @@ -837,9 +823,7 @@ Possible Output: */ @(require_results) int_range :: proc(lo, hi: int, gen := context.random_generator) -> (val: int) { - if lo >= hi { - panic("Invalid arguments to int_range: lo must be less than hi") - } + assert(lo < hi, "Invalid arguments to int_range: lo must be less than hi") when size_of(int) == 4 { return int(int32_range(i32(lo), i32(hi), gen)) } else { |