1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-20 14:45:44 +00:00

Merge pull request #102419 from Ivorforce/std-size

Use `std::size` instead of `sizeof(a) / sizeof(a[0])` pattern throughout the codebase.
This commit is contained in:
Thaddeus Crews
2025-03-07 15:12:25 -06:00
33 changed files with 71 additions and 67 deletions

View File

@@ -35,23 +35,25 @@
#include "char_range.inc"
#define BSEARCH_CHAR_RANGE(m_array) \
int low = 0; \
int high = sizeof(m_array) / sizeof(m_array[0]) - 1; \
int middle = (low + high) / 2; \
\
while (low <= high) { \
if (p_char < m_array[middle].start) { \
high = middle - 1; \
} else if (p_char > m_array[middle].end) { \
low = middle + 1; \
} else { \
return true; \
} \
\
middle = (low + high) / 2; \
} \
\
#include <iterator>
#define BSEARCH_CHAR_RANGE(m_array) \
int low = 0; \
int high = std::size(m_array) - 1; \
int middle = (low + high) / 2; \
\
while (low <= high) { \
if (p_char < m_array[middle].start) { \
high = middle - 1; \
} else if (p_char > m_array[middle].end) { \
low = middle + 1; \
} else { \
return true; \
} \
\
middle = (low + high) / 2; \
} \
\
return false
constexpr bool is_unicode_identifier_start(char32_t p_char) {