From ea1848ce0a5f03c3a9f7e0a221350f4f4044bb08 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Thu, 29 Sep 2022 09:18:07 +0300 Subject: Use `constexpr` in the conditions with template parameters and `sizeof`s to suppress C4127 warnings. --- core/extension/gdnative_interface.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'core/extension') diff --git a/core/extension/gdnative_interface.cpp b/core/extension/gdnative_interface.cpp index 67dc55bdb7..193fcb8916 100644 --- a/core/extension/gdnative_interface.cpp +++ b/core/extension/gdnative_interface.cpp @@ -559,7 +559,7 @@ static void gdnative_string_new_with_utf32_chars(GDNativeStringPtr r_dest, const static void gdnative_string_new_with_wide_chars(GDNativeStringPtr r_dest, const wchar_t *p_contents) { String *dest = (String *)r_dest; - if (sizeof(wchar_t) == 2) { + if constexpr (sizeof(wchar_t) == 2) { // wchar_t is 16 bit, parse. memnew_placement(dest, String); dest->parse_utf16((const char16_t *)p_contents); @@ -596,7 +596,7 @@ static void gdnative_string_new_with_utf32_chars_and_len(GDNativeStringPtr r_des static void gdnative_string_new_with_wide_chars_and_len(GDNativeStringPtr r_dest, const wchar_t *p_contents, const GDNativeInt p_size) { String *dest = (String *)r_dest; - if (sizeof(wchar_t) == 2) { + if constexpr (sizeof(wchar_t) == 2) { // wchar_t is 16 bit, parse. memnew_placement(dest, String); dest->parse_utf16((const char16_t *)p_contents, p_size); @@ -655,7 +655,7 @@ static GDNativeInt gdnative_string_to_utf32_chars(const GDNativeStringPtr p_self return len; } static GDNativeInt gdnative_string_to_wide_chars(const GDNativeStringPtr p_self, wchar_t *r_text, GDNativeInt p_max_write_length) { - if (sizeof(wchar_t) == 4) { + if constexpr (sizeof(wchar_t) == 4) { return gdnative_string_to_utf32_chars(p_self, (char32_t *)r_text, p_max_write_length); } else { return gdnative_string_to_utf16_chars(p_self, (char16_t *)r_text, p_max_write_length); -- cgit v1.2.3