Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use std::size instead of sizeof(a) / sizeof(a[0]) pattern throughout the codebase. #102419

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion core/error/error_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#include "error_list.h"

#include <array>

const char *error_names[] = {
"OK", // OK
"Failed", // FAILED
Expand Down Expand Up @@ -82,4 +84,4 @@ const char *error_names[] = {
"Printer on fire", // ERR_PRINTER_ON_FIRE
};

static_assert(sizeof(error_names) / sizeof(*error_names) == ERR_MAX);
static_assert(std::size(error_names) == ERR_MAX);
2 changes: 1 addition & 1 deletion core/input/input_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ static const _BuiltinActionDisplayName _builtin_action_display_names[] = {
};

String InputMap::get_builtin_display_name(const String &p_name) const {
int len = sizeof(_builtin_action_display_names) / sizeof(_BuiltinActionDisplayName);
constexpr int len = std::size(_builtin_action_display_names);

for (int i = 0; i < len; i++) {
if (_builtin_action_display_names[i].name == p_name) {
Expand Down
2 changes: 1 addition & 1 deletion core/io/file_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ class CharBuffer {
public:
_FORCE_INLINE_ CharBuffer() :
buffer(stack_buffer),
capacity(sizeof(stack_buffer) / sizeof(char)) {
capacity(std::size(stack_buffer)) {
}

_FORCE_INLINE_ void push_back(char c) {
Expand Down
2 changes: 1 addition & 1 deletion core/io/resource_uid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ String ResourceUID::get_cache_file() {
}

static constexpr uint8_t uuid_characters[] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', '0', '1', '2', '3', '4', '5', '6', '7', '8' };
static constexpr uint32_t uuid_characters_element_count = (sizeof(uuid_characters) / sizeof(*uuid_characters));
static constexpr uint32_t uuid_characters_element_count = std::size(uuid_characters);
static constexpr uint8_t max_uuid_number_length = 13; // Max 0x7FFFFFFFFFFFFFFF (uid://d4n4ub6itg400) size is 13 characters.

String ResourceUID::id_to_text(ID p_id) const {
Expand Down
2 changes: 1 addition & 1 deletion core/math/color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ int Color::find_named_color(const String &p_name) {
}

int Color::get_named_color_count() {
return sizeof(named_colors) / sizeof(NamedColor);
return std::size(named_colors);
}

String Color::get_named_color_name(int p_idx) {
Expand Down
36 changes: 19 additions & 17 deletions core/string/char_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <array>

#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) {
Expand Down
2 changes: 1 addition & 1 deletion core/string/translation_domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const char32_t *TranslationDomain::_get_accented_version(char32_t p_character) c
return nullptr;
}

for (unsigned int i = 0; i < sizeof(_character_to_accented) / sizeof(_character_to_accented[0]); i++) {
for (unsigned int i = 0; i < std::size(_character_to_accented); i++) {
if (_character_to_accented[i].character == p_character) {
return _character_to_accented[i].accented_character;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/d3d12/rendering_context_driver_d3d12.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

using Microsoft::WRL::ComPtr;

#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#define ARRAY_SIZE(a) std::size(a)

class RenderingContextDriverD3D12 : public RenderingContextDriver {
ComPtr<ID3D12DeviceFactory> device_factory;
Expand Down
2 changes: 1 addition & 1 deletion drivers/d3d12/rendering_device_driver_d3d12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3378,7 +3378,7 @@ Vector<uint8_t> RenderingDeviceDriverD3D12::shader_compile_binary_from_spirv(Vec
binary_data.nir_runtime_data_root_param_idx = root_params.size();
CD3DX12_ROOT_PARAMETER1 nir_runtime_data;
nir_runtime_data.InitAsConstants(
sizeof(dxil_spirv_vertex_runtime_data) / sizeof(uint32_t),
std::size(dxil_spirv_vertex_runtime_data),
RUNTIME_DATA_REGISTER,
0,
D3D12_SHADER_VISIBILITY_VERTEX);
Expand Down
2 changes: 1 addition & 1 deletion drivers/vulkan/rendering_device_driver_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#include "thirdparty/swappy-frame-pacing/swappyVk.h"
#endif

#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#define ARRAY_SIZE(a) std::size(a)

#define PRINT_NATIVE_COMMANDS 0

Expand Down
2 changes: 1 addition & 1 deletion editor/code_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1917,7 +1917,7 @@ CodeTextEditor::CodeTextEditor() {
zoom_button->set_text("100 %");

PopupMenu *zoom_menu = zoom_button->get_popup();
int preset_count = sizeof(ZOOM_FACTOR_PRESETS) / sizeof(float);
constexpr int preset_count = std::size(ZOOM_FACTOR_PRESETS);

for (int i = 0; i < preset_count; i++) {
float z = ZOOM_FACTOR_PRESETS[i];
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/animation_state_machine_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co
state_machine_draw->draw_line(p_from, p_from.lerp(p_to, p_fade_ratio), fade_line_color, 2);
}

const int ICON_COUNT = sizeof(theme_cache.transition_icons) / sizeof(*theme_cache.transition_icons);
const int ICON_COUNT = std::size(theme_cache.transition_icons);
int icon_index = p_mode + (p_auto_advance ? ICON_COUNT / 2 : 0);
ERR_FAIL_COND(icon_index >= ICON_COUNT);
Ref<Texture2D> icon = theme_cache.transition_icons[icon_index];
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/visual_shader_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static FloatConstantDef float_constant_defs[] = {
{ "Sqrt2", Math_SQRT2, TTRC("Sqrt2 constant (1.414214). Square root of 2.") }
};

const int MAX_FLOAT_CONST_DEFS = sizeof(float_constant_defs) / sizeof(FloatConstantDef);
constexpr int MAX_FLOAT_CONST_DEFS = std::size(float_constant_defs);

///////////////////

Expand Down
2 changes: 1 addition & 1 deletion editor/themes/editor_fonts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void editor_register_fonts(const Ref<Theme> &p_theme) {
String noto_cjk_path;
String noto_cjk_bold_path;
String var_suffix[] = { "HK", "KR", "SC", "TC", "JP" }; // Note: All Noto Sans CJK versions support all glyph variations, it should not match current locale.
for (size_t i = 0; i < sizeof(var_suffix) / sizeof(String); i++) {
for (size_t i = 0; i < std::size(var_suffix); i++) {
if (noto_cjk_path.is_empty()) {
noto_cjk_path = OS::get_singleton()->get_system_font_path("Noto Sans CJK " + var_suffix[i], 400, 100);
}
Expand Down
2 changes: 1 addition & 1 deletion main/performance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ String Performance::get_monitor_name(Monitor p_monitor) const {
PNAME("pipeline/compilations_draw"),
PNAME("pipeline/compilations_specialization"),
};
static_assert((sizeof(names) / sizeof(const char *)) == MONITOR_MAX);
static_assert(std::size(names) == MONITOR_MAX);

return names[p_monitor];
}
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/gdscript_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4129,7 +4129,7 @@ GDScriptParser::ParseRule *GDScriptParser::get_rule(GDScriptTokenizer::Token::Ty
};
/* clang-format on */
// Avoid desync.
static_assert(sizeof(rules) / sizeof(rules[0]) == GDScriptTokenizer::Token::TK_MAX, "Amount of parse rules don't match the amount of token types.");
static_assert(std::size(rules) == GDScriptTokenizer::Token::TK_MAX, "Amount of parse rules don't match the amount of token types.");

// Let's assume this is never invalid, since nothing generates a TK_MAX.
return &rules[p_token_type];
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/gdscript_tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static const char *token_names[] = {
};

// Avoid desync.
static_assert(sizeof(token_names) / sizeof(token_names[0]) == GDScriptTokenizer::Token::TK_MAX, "Amount of token names don't match the amount of token types.");
static_assert(std::size(token_names) == GDScriptTokenizer::Token::TK_MAX, "Amount of token names don't match the amount of token types.");

const char *GDScriptTokenizer::Token::get_name() const {
ERR_FAIL_INDEX_V_MSG(type, TK_MAX, "<error>", "Using token type out of the enum.");
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/gdscript_vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ void (*type_init_function_table[])(Variant *) = {
&&OPCODE_LINE, \
&&OPCODE_END \
}; \
static_assert((sizeof(switch_table_ops) / sizeof(switch_table_ops[0]) == (OPCODE_END + 1)), "Opcodes in jump table aren't the same as opcodes in enum.");
static_assert(std::size(switch_table_ops) == (OPCODE_END + 1), "Opcodes in jump table aren't the same as opcodes in enum.");

#define OPCODE(m_op) \
m_op:
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/gdscript_warning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ String GDScriptWarning::get_name_from_code(Code p_code) {
#endif
};

static_assert((sizeof(names) / sizeof(*names)) == WARNING_MAX, "Amount of warning types don't match the amount of warning names.");
static_assert(std::size(names) == WARNING_MAX, "Amount of warning types don't match the amount of warning names.");

return names[(int)p_code];
}
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/gdscript_warning.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class GDScriptWarning {
#endif
};

static_assert((sizeof(default_warning_levels) / sizeof(default_warning_levels[0])) == WARNING_MAX, "Amount of default levels does not match the amount of warnings.");
static_assert(std::size(default_warning_levels) == WARNING_MAX, "Amount of default levels does not match the amount of warnings.");

Code code = WARNING_MAX;
int start_line = -1, end_line = -1;
Expand Down
2 changes: 1 addition & 1 deletion modules/mono/mono_gd/gd_mono.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ godot_plugins_initialize_fn initialize_coreclr_and_godot_plugins(bool &r_runtime
String tpa_list = make_tpa_list();
const char *prop_keys[] = { "TRUSTED_PLATFORM_ASSEMBLIES" };
const char *prop_values[] = { tpa_list.utf8().get_data() };
int nprops = sizeof(prop_keys) / sizeof(prop_keys[0]);
constexpr int nprops = std::size(prop_keys);

void *coreclr_handle = nullptr;
unsigned int domain_id = 0;
Expand Down
2 changes: 1 addition & 1 deletion platform/android/export/gradle_export_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ String _get_gles_tag() {
String _get_screen_sizes_tag(const Ref<EditorExportPreset> &p_preset) {
String manifest_screen_sizes = " <supports-screens \n tools:node=\"replace\"";
String sizes[] = { "small", "normal", "large", "xlarge" };
size_t num_sizes = sizeof(sizes) / sizeof(sizes[0]);
constexpr size_t num_sizes = std::size(sizes);
for (size_t i = 0; i < num_sizes; i++) {
String feature_name = vformat("screen/support_%s", sizes[i]);
String feature_support = bool_to_string(p_preset->get(feature_name));
Expand Down
16 changes: 8 additions & 8 deletions platform/ios/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options)
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/photolibrary_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need access to the photo library"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/photolibrary_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));

for (uint64_t i = 0; i < sizeof(api_info) / sizeof(api_info[0]); ++i) {
for (uint64_t i = 0; i < std::size(api_info); ++i) {
String prop_name = vformat("privacy/%s_access_reasons", api_info[i].prop_name);
String hint;
for (int j = 0; j < api_info[i].prop_flag_value.size(); j++) {
Expand All @@ -371,13 +371,13 @@ void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options)

{
String hint;
for (uint64_t i = 0; i < sizeof(data_collect_purpose_info) / sizeof(data_collect_purpose_info[0]); ++i) {
for (uint64_t i = 0; i < std::size(data_collect_purpose_info); ++i) {
if (i != 0) {
hint += ",";
}
hint += vformat("%s:%d", data_collect_purpose_info[i].prop_name, (1 << i));
}
for (uint64_t i = 0; i < sizeof(data_collect_type_info) / sizeof(data_collect_type_info[0]); ++i) {
for (uint64_t i = 0; i < std::size(data_collect_type_info); ++i) {
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, vformat("privacy/collected_data/%s/collected", data_collect_type_info[i].prop_name)), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, vformat("privacy/collected_data/%s/linked_to_user", data_collect_type_info[i].prop_name)), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, vformat("privacy/collected_data/%s/used_for_tracking", data_collect_type_info[i].prop_name)), false));
Expand All @@ -390,7 +390,7 @@ void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options)
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "icons/icon_1024x1024_tinted", PROPERTY_HINT_FILE, "*.svg,*.png,*.webp,*.jpg,*.jpeg"), ""));

HashSet<String> used_names;
for (uint64_t i = 0; i < sizeof(icon_infos) / sizeof(icon_infos[0]); ++i) {
for (uint64_t i = 0; i < std::size(icon_infos); ++i) {
if (!used_names.has(icon_infos[i].preset_key)) {
used_names.insert(icon_infos[i].preset_key);
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, String(icon_infos[i].preset_key), PROPERTY_HINT_FILE, "*.png,*.jpg,*.jpeg"), ""));
Expand Down Expand Up @@ -768,7 +768,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
strnew += lines[i].replace("$swift_runtime_build_phase", value) + "\n";
} else if (lines[i].contains("$priv_collection")) {
bool section_opened = false;
for (uint64_t j = 0; j < sizeof(data_collect_type_info) / sizeof(data_collect_type_info[0]); ++j) {
for (uint64_t j = 0; j < std::size(data_collect_type_info); ++j) {
bool data_collected = p_preset->get(vformat("privacy/collected_data/%s/collected", data_collect_type_info[j].prop_name));
bool linked = p_preset->get(vformat("privacy/collected_data/%s/linked_to_user", data_collect_type_info[j].prop_name));
bool tracking = p_preset->get(vformat("privacy/collected_data/%s/used_for_tracking", data_collect_type_info[j].prop_name));
Expand Down Expand Up @@ -797,7 +797,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
if (purposes != 0) {
strnew += "\t\t\t\t<key>NSPrivacyCollectedDataTypePurposes</key>\n";
strnew += "\t\t\t\t<array>\n";
for (uint64_t k = 0; k < sizeof(data_collect_purpose_info) / sizeof(data_collect_purpose_info[0]); ++k) {
for (uint64_t k = 0; k < std::size(data_collect_purpose_info); ++k) {
if (purposes & (1 << k)) {
strnew += vformat("\t\t\t\t\t<string>%s</string>\n", data_collect_purpose_info[k].type_name);
}
Expand Down Expand Up @@ -829,7 +829,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
}
} else if (lines[i].contains("$priv_api_types")) {
strnew += "\t<array>\n";
for (uint64_t j = 0; j < sizeof(api_info) / sizeof(api_info[0]); ++j) {
for (uint64_t j = 0; j < std::size(api_info); ++j) {
int api_access = p_preset->get(vformat("privacy/%s_access_reasons", api_info[j].prop_name));
if (api_access != 0) {
strnew += "\t\t<dict>\n";
Expand Down Expand Up @@ -949,7 +949,7 @@ Error EditorExportPlatformIOS::_export_icons(const Ref<EditorExportPreset> &p_pr
};

bool first_icon = true;
for (uint64_t i = 0; i < (sizeof(icon_infos) / sizeof(icon_infos[0])); ++i) {
for (uint64_t i = 0; i < std::size(icon_infos); ++i) {
for (int color_mode = ICON_NORMAL; color_mode < ICON_MAX; color_mode++) {
IconInfo info = icon_infos[i];
int side_size = String(info.actual_size_side).to_int();
Expand Down
4 changes: 2 additions & 2 deletions platform/linuxbsd/os_linuxbsd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void OS_LinuxBSD::alert(const String &p_alert, const String &p_title) {
String program;

for (int i = 0; i < path_elems.size(); i++) {
for (uint64_t k = 0; k < sizeof(message_programs) / sizeof(char *); k++) {
for (uint64_t k = 0; k < std::size(message_programs); k++) {
String tested_path = path_elems[i].path_join(message_programs[k]);

if (FileAccess::exists(tested_path)) {
Expand Down Expand Up @@ -751,7 +751,7 @@ Vector<String> OS_LinuxBSD::get_system_font_path_for_text(const String &p_font_n

Vector<String> ret;
static const char *allowed_formats[] = { "TrueType", "CFF" };
for (size_t i = 0; i < sizeof(allowed_formats) / sizeof(const char *); i++) {
for (size_t i = 0; i < std::size(allowed_formats); i++) {
FcPattern *pattern = FcPatternCreate();
if (pattern) {
FcPatternAddBool(pattern, FC_SCALABLE, FcTrue);
Expand Down
2 changes: 1 addition & 1 deletion platform/linuxbsd/x11/display_server_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3894,7 +3894,7 @@ Atom DisplayServerX11::_process_selection_request_target(Atom p_target, Window p
32,
PropModeReplace,
(unsigned char *)&data,
sizeof(data) / sizeof(data[0]));
std::size(data));
return p_property;
} else if (p_target == XInternAtom(x11_display, "SAVE_TARGETS", 0)) {
// Request to check if SAVE_TARGETS is supported, nothing special to do.
Expand Down
10 changes: 5 additions & 5 deletions platform/macos/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,13 +561,13 @@ void EditorExportPlatformMacOS::get_export_options(List<ExportOption> *r_options

{
String hint;
for (uint64_t i = 0; i < sizeof(data_collect_purpose_info) / sizeof(data_collect_purpose_info[0]); ++i) {
for (uint64_t i = 0; i < std::size(data_collect_purpose_info); ++i) {
if (i != 0) {
hint += ",";
}
hint += vformat("%s:%d", data_collect_purpose_info[i].prop_name, (1 << i));
}
for (uint64_t i = 0; i < sizeof(data_collect_type_info) / sizeof(data_collect_type_info[0]); ++i) {
for (uint64_t i = 0; i < std::size(data_collect_type_info); ++i) {
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, vformat("privacy/collected_data/%s/collected", data_collect_type_info[i].prop_name)), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, vformat("privacy/collected_data/%s/linked_to_user", data_collect_type_info[i].prop_name)), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, vformat("privacy/collected_data/%s/used_for_tracking", data_collect_type_info[i].prop_name)), false));
Expand Down Expand Up @@ -671,7 +671,7 @@ void EditorExportPlatformMacOS::_make_icon(const Ref<EditorExportPreset> &p_pres
{ "is32", "s8mk", false, 16 } //16×16 24-bit RLE + 8-bit uncompressed mask
};

for (uint64_t i = 0; i < (sizeof(icon_infos) / sizeof(icon_infos[0])); ++i) {
for (uint64_t i = 0; i < std::size(icon_infos); ++i) {
Ref<Image> copy = p_icon->duplicate();
copy->convert(Image::FORMAT_RGBA8);
copy->resize(icon_infos[i].size, icon_infos[i].size, (Image::Interpolation)(p_preset->get("application/icon_interpolation").operator int()));
Expand Down Expand Up @@ -743,7 +743,7 @@ void EditorExportPlatformMacOS::_fix_privacy_manifest(const Ref<EditorExportPres
for (int i = 0; i < lines.size(); i++) {
if (lines[i].find("$priv_collection") != -1) {
bool section_opened = false;
for (uint64_t j = 0; j < sizeof(data_collect_type_info) / sizeof(data_collect_type_info[0]); ++j) {
for (uint64_t j = 0; j < std::size(data_collect_type_info); ++j) {
bool data_collected = p_preset->get(vformat("privacy/collected_data/%s/collected", data_collect_type_info[j].prop_name));
bool linked = p_preset->get(vformat("privacy/collected_data/%s/linked_to_user", data_collect_type_info[j].prop_name));
bool tracking = p_preset->get(vformat("privacy/collected_data/%s/used_for_tracking", data_collect_type_info[j].prop_name));
Expand Down Expand Up @@ -772,7 +772,7 @@ void EditorExportPlatformMacOS::_fix_privacy_manifest(const Ref<EditorExportPres
if (purposes != 0) {
strnew += "\t\t\t\t<key>NSPrivacyCollectedDataTypePurposes</key>\n";
strnew += "\t\t\t\t<array>\n";
for (uint64_t k = 0; k < sizeof(data_collect_purpose_info) / sizeof(data_collect_purpose_info[0]); ++k) {
for (uint64_t k = 0; k < std::size(data_collect_purpose_info); ++k) {
if (purposes & (1 << k)) {
strnew += vformat("\t\t\t\t\t<string>%s</string>\n", data_collect_purpose_info[k].type_name);
}
Expand Down
2 changes: 1 addition & 1 deletion platform/macos/key_mapping_macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@
LMGetKbdType(),
kUCKeyTranslateNoDeadKeysBit,
&keys_down,
sizeof(chars) / sizeof(chars[0]),
std::size(chars),
&real_length,
chars);

Expand Down
Loading
Loading