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 <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Ahmad Samir 2023-05-15 00:37:09 +03:00
parent a2abca317a
commit 5c7702a8f9

View File

@ -6,6 +6,8 @@
#include <QtCore/qglobal.h>
#include <algorithm>
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)