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
commit c937b6d180
No known key found for this signature in database
GPG key ID: 62181B86FE9E5D84
33 changed files with 71 additions and 67 deletions

View file

@ -5245,7 +5245,7 @@ ShaderLanguage::DataType ShaderLanguage::get_scalar_type(DataType p_type) {
TYPE_VOID,
};
static_assert(sizeof(scalar_types) / sizeof(*scalar_types) == TYPE_MAX);
static_assert(std::size(scalar_types) == TYPE_MAX);
return scalar_types[p_type];
}
@ -5287,7 +5287,7 @@ int ShaderLanguage::get_cardinality(DataType p_type) {
1,
};
static_assert(sizeof(cardinality_table) / sizeof(*cardinality_table) == TYPE_MAX);
static_assert(std::size(cardinality_table) == TYPE_MAX);
return cardinality_table[p_type];
}
@ -11231,7 +11231,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_
#ifdef DEBUG_ENABLED
// Adds context keywords.
if (keyword_completion_context != CF_UNSPECIFIED) {
int sz = sizeof(keyword_list) / sizeof(KeyWord);
constexpr int sz = std::size(keyword_list);
for (int i = 0; i < sz; i++) {
if (keyword_list[i].flags == CF_UNSPECIFIED) {
break; // Ignore hint keywords (parsed below).