Cleanup: use UNLIKELY(..) for integer overflow checks

This commit is contained in:
Campbell Barton
2025-07-24 22:02:49 +10:00
parent 21d431d214
commit bc69b25382

View File

@@ -5490,7 +5490,7 @@ void rna_iterator_array_begin(CollectionPropertyIterator *iter,
data = nullptr;
itemsize = 0;
}
else if (length < 0 || length > std::numeric_limits<uint64_t>::max() / itemsize) {
else if (UNLIKELY(length < 0 || length > std::numeric_limits<uint64_t>::max() / itemsize)) {
/* This path is never expected to execute. Assert and trace if it ever does. */
BLI_assert_unreachable();
data = nullptr;
@@ -5556,7 +5556,7 @@ PointerRNA rna_array_lookup_int(
if (index < 0 || index >= length) {
return PointerRNA_NULL;
}
if (index > std::numeric_limits<uint64_t>::max() / itemsize) {
if (UNLIKELY(index > std::numeric_limits<uint64_t>::max() / itemsize)) {
/* This path is never expected to execute. Assert and trace if it ever does. */
BLI_assert_unreachable();
return PointerRNA_NULL;