aboutsummaryrefslogtreecommitdiff
path: root/src/array.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-12-18 23:26:44 +0000
committergingerBill <bill@gingerbill.org>2022-12-18 23:26:44 +0000
commit01b508f18222a34ee8b47ede54798dc877d93e81 (patch)
treef21525b4770783a6dbaca38f93aea12671e999f8 /src/array.cpp
parent2a8fa8612de858d40b0812913817c8550db11630 (diff)
Use `usize` for bounds checking in `Array` and `Slice` (compiler)
Diffstat (limited to 'src/array.cpp')
-rw-r--r--src/array.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/array.cpp b/src/array.cpp
index c633078f6..f1a1f93e2 100644
--- a/src/array.cpp
+++ b/src/array.cpp
@@ -10,14 +10,14 @@ struct Array {
T &operator[](isize index) {
#if !defined(NO_ARRAY_BOUNDS_CHECK)
- GB_ASSERT_MSG(0 <= index && index < count, "Index %td is out of bounds ranges 0..<%td", index, count);
+ GB_ASSERT_MSG(cast(usize)index < cast(usize)count, "Index %td is out of bounds ranges 0..<%td", index, count);
#endif
return data[index];
}
T const &operator[](isize index) const {
#if !defined(NO_ARRAY_BOUNDS_CHECK)
- GB_ASSERT_MSG(0 <= index && index < count, "Index %td is out of bounds ranges 0..<%td", index, count);
+ GB_ASSERT_MSG(cast(usize)index < cast(usize)count, "Index %td is out of bounds ranges 0..<%td", index, count);
#endif
return data[index];
}
@@ -58,14 +58,14 @@ struct Slice {
gb_inline T &operator[](isize index) {
#if !defined(NO_ARRAY_BOUNDS_CHECK)
- GB_ASSERT_MSG(0 <= index && index < count, "Index %td is out of bounds ranges 0..<%td", index, count);
+ GB_ASSERT_MSG(cast(usize)index < cast(usize)count, "Index %td is out of bounds ranges 0..<%td", index, count);
#endif
return data[index];
}
gb_inline T const &operator[](isize index) const {
#if !defined(NO_ARRAY_BOUNDS_CHECK)
- GB_ASSERT_MSG(0 <= index && index < count, "Index %td is out of bounds ranges 0..<%td", index, count);
+ GB_ASSERT_MSG(cast(usize)index < cast(usize)count, "Index %td is out of bounds ranges 0..<%td", index, count);
#endif
return data[index];
}