diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-12-07 15:59:37 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-12-07 15:59:37 -0500 |
| commit | a201939a8150bc4c2f221925797ea2751c74b77c (patch) | |
| tree | 26fee4ec601319fd8771435087931023e393fe92 /stdlib/arrays.c | |
| parent | 683b0f5141ad21914d77cd4b4b81e7e2161f90f3 (diff) | |
Use likely()/unlikely() macros and a few bugfixes for integers
Diffstat (limited to 'stdlib/arrays.c')
| -rw-r--r-- | stdlib/arrays.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/stdlib/arrays.c b/stdlib/arrays.c index c740a1c7..fd4dcf96 100644 --- a/stdlib/arrays.c +++ b/stdlib/arrays.c @@ -430,7 +430,7 @@ public Array_t Array$by(Array_t array, Int_t int_stride, int64_t padded_item_siz int64_t stride = Int_to_Int64(int_stride, false); // In the unlikely event that the stride value would be too large to fit in // a 15-bit integer, fall back to creating a copy of the array: - if (__builtin_expect(array.stride*stride < ARRAY_MIN_STRIDE || array.stride*stride > ARRAY_MAX_STRIDE, 0)) { + if (unlikely(array.stride*stride < ARRAY_MIN_STRIDE || array.stride*stride > ARRAY_MAX_STRIDE)) { void *copy = NULL; int64_t len = (stride < 0 ? array.length / -stride : array.length / stride) + ((array.length % stride) != 0); if (len > 0) { @@ -465,7 +465,7 @@ public Array_t Array$reversed(Array_t array, int64_t padded_item_size) // 15-bit integer, fall back to Array$by()'s more general method of copying // the array. This should only happen if array.stride is MIN_STRIDE to // begin with (very unlikely). - if (__builtin_expect(-array.stride < ARRAY_MIN_STRIDE || -array.stride > ARRAY_MAX_STRIDE, 0)) + if (unlikely(-array.stride < ARRAY_MIN_STRIDE || -array.stride > ARRAY_MAX_STRIDE)) return Array$by(array, I(-1), padded_item_size); Array_t reversed = array; |
