QMetaObject: port qRemoveWhitespace() to QByteArrayView
Change-Id: Ib5754708f25bdb3ac9d6546deaf3182dbb7ed8a8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
054dfb50a0
commit
0c0b5d0ff0
@ -1312,17 +1312,19 @@ bool QMetaObject::checkConnectArgs(const QMetaMethod &signal,
|
|||||||
QMetaMethodPrivate::get(&method));
|
QMetaMethodPrivate::get(&method));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qRemoveWhitespace(const char *s, char *d)
|
static void qRemoveWhitespace(QByteArrayView str, char *d)
|
||||||
{
|
{
|
||||||
char last = 0;
|
char last = 0;
|
||||||
while (*s && is_space(*s))
|
const char *s = str.begin();
|
||||||
|
const char *end = str.end();
|
||||||
|
while (s != end && is_space(*s))
|
||||||
s++;
|
s++;
|
||||||
while (*s) {
|
while (s != end) {
|
||||||
while (*s && !is_space(*s))
|
while (s != end && !is_space(*s))
|
||||||
last = *d++ = *s++;
|
last = *d++ = *s++;
|
||||||
while (*s && is_space(*s))
|
while (s != end && is_space(*s))
|
||||||
s++;
|
s++;
|
||||||
if (*s && ((is_ident_char(*s) && is_ident_char(last))
|
if (s != end && ((is_ident_char(*s) && is_ident_char(last))
|
||||||
|| ((*s == ':') && (last == '<')))) {
|
|| ((*s == ':') && (last == '<')))) {
|
||||||
last = *d++ = ' ';
|
last = *d++ = ' ';
|
||||||
}
|
}
|
||||||
@ -1388,7 +1390,7 @@ QByteArray QMetaObject::normalizedSignature(const char *method)
|
|||||||
int len = int(strlen(method));
|
int len = int(strlen(method));
|
||||||
QVarLengthArray<char> stackbuf(len + 1);
|
QVarLengthArray<char> stackbuf(len + 1);
|
||||||
char *d = stackbuf.data();
|
char *d = stackbuf.data();
|
||||||
qRemoveWhitespace(method, d);
|
qRemoveWhitespace(QByteArrayView{method, len}, d);
|
||||||
|
|
||||||
result.reserve(len);
|
result.reserve(len);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user