From 5c7702a8f9c8cf3722945b643dc3d21303c2482c Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Mon, 15 May 2023 00:37:09 +0300 Subject: [PATCH] moc/utils.h: fix a narrowing conversion warning By taking a qsizetype, and using std::all_of. Pick-to: 6.5 Change-Id: If81465194d92d04af637b0032d9504d6524893aa Reviewed-by: Fabian Kosmale Reviewed-by: Thiago Macieira --- src/tools/moc/utils.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/tools/moc/utils.h b/src/tools/moc/utils.h index 358780a33d..cb118fab38 100644 --- a/src/tools/moc/utils.h +++ b/src/tools/moc/utils.h @@ -6,6 +6,8 @@ #include +#include + QT_BEGIN_NAMESPACE inline bool is_whitespace(char s) @@ -35,16 +37,11 @@ inline bool is_ident_char(char s) ); } -inline bool is_identifier(const char *s, int len) +inline bool is_identifier(const char *s, qsizetype len) { if (len < 1) return false; - if (!is_ident_start(*s)) - return false; - for (int i = 1; i < len; ++i) - if (!is_ident_char(s[i])) - return false; - return true; + return std::all_of(s, s + len, is_ident_char); } inline bool is_digit_char(char s)