Replace QString::utf16 with QString::data where appropriate
QString::utf16() needlessly detaches fromRawData() to ensure a terminating NUL. Use data() where we don't require said NUL, taking care not call the mutable data() overload, which would detach, too. Task-number: QTBUG-98763 Change-Id: Ibd5e56798c0c666893c12c91ff0881842b8430c7 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
88dda89329
commit
74955f386d
@ -2172,7 +2172,7 @@ QString qt_normalizePathSegments(const QString &name, QDirPrivate::PathNormaliza
|
|||||||
QVarLengthArray<char16_t> outVector(len);
|
QVarLengthArray<char16_t> outVector(len);
|
||||||
int used = len;
|
int used = len;
|
||||||
char16_t *out = outVector.data();
|
char16_t *out = outVector.data();
|
||||||
const ushort *p = name.utf16();
|
const ushort *p = reinterpret_cast<const ushort *>(name.data());
|
||||||
const ushort *prefix = p;
|
const ushort *prefix = p;
|
||||||
int up = 0;
|
int up = 0;
|
||||||
|
|
||||||
|
@ -992,7 +992,7 @@ inline bool QUrlPrivate::setScheme(const QString &value, int len, bool doSetErro
|
|||||||
|
|
||||||
// validate it:
|
// validate it:
|
||||||
int needsLowercasing = -1;
|
int needsLowercasing = -1;
|
||||||
const ushort *p = value.utf16();
|
const ushort *p = reinterpret_cast<const ushort *>(value.data());
|
||||||
for (int i = 0; i < len; ++i) {
|
for (int i = 0; i < len; ++i) {
|
||||||
if (p[i] >= 'a' && p[i] <= 'z')
|
if (p[i] >= 'a' && p[i] <= 'z')
|
||||||
continue;
|
continue;
|
||||||
|
@ -910,7 +910,7 @@ bool Parser::parseString()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
container->appendByteData(reinterpret_cast<const char *>(ucs4.utf16()), ucs4.size() * 2,
|
container->appendByteData(reinterpret_cast<const char *>(ucs4.constData()), ucs4.size() * 2,
|
||||||
QCborValue::String, QtCbor::Element::StringIsUtf16);
|
QCborValue::String, QtCbor::Element::StringIsUtf16);
|
||||||
END;
|
END;
|
||||||
return true;
|
return true;
|
||||||
|
@ -1599,11 +1599,11 @@ static QByteArray qSspiStartup(QAuthenticatorPrivate *ctx, QAuthenticatorPrivate
|
|||||||
auth.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
|
auth.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
|
||||||
bool useAuth = false;
|
bool useAuth = false;
|
||||||
if (method == QAuthenticatorPrivate::Negotiate && !ctx->user.isEmpty()) {
|
if (method == QAuthenticatorPrivate::Negotiate && !ctx->user.isEmpty()) {
|
||||||
auth.Domain = const_cast<ushort *>(ctx->userDomain.utf16());
|
auth.Domain = const_cast<ushort *>(reinterpret_cast<const ushort *>(ctx->userDomain.constData()));
|
||||||
auth.DomainLength = ctx->userDomain.size();
|
auth.DomainLength = ctx->userDomain.size();
|
||||||
auth.User = const_cast<ushort *>(ctx->user.utf16());
|
auth.User = const_cast<ushort *>(reinterpret_cast<const ushort *>(ctx->user.constData()));
|
||||||
auth.UserLength = ctx->user.size();
|
auth.UserLength = ctx->user.size();
|
||||||
auth.Password = const_cast<ushort *>(ctx->password.utf16());
|
auth.Password = const_cast<ushort *>(reinterpret_cast<const ushort *>(ctx->password.constData()));
|
||||||
auth.PasswordLength = ctx->password.size();
|
auth.PasswordLength = ctx->password.size();
|
||||||
useAuth = true;
|
useAuth = true;
|
||||||
}
|
}
|
||||||
|
@ -524,7 +524,7 @@ bool QSQLiteResult::exec()
|
|||||||
case QMetaType::QDateTime: {
|
case QMetaType::QDateTime: {
|
||||||
const QDateTime dateTime = value.toDateTime();
|
const QDateTime dateTime = value.toDateTime();
|
||||||
const QString str = dateTime.toString(Qt::ISODateWithMs);
|
const QString str = dateTime.toString(Qt::ISODateWithMs);
|
||||||
res = sqlite3_bind_text16(d->stmt, i + 1, str.utf16(),
|
res = sqlite3_bind_text16(d->stmt, i + 1, str.data(),
|
||||||
int(str.size() * sizeof(ushort)),
|
int(str.size() * sizeof(ushort)),
|
||||||
SQLITE_TRANSIENT);
|
SQLITE_TRANSIENT);
|
||||||
break;
|
break;
|
||||||
@ -532,7 +532,7 @@ bool QSQLiteResult::exec()
|
|||||||
case QMetaType::QTime: {
|
case QMetaType::QTime: {
|
||||||
const QTime time = value.toTime();
|
const QTime time = value.toTime();
|
||||||
const QString str = time.toString(u"hh:mm:ss.zzz");
|
const QString str = time.toString(u"hh:mm:ss.zzz");
|
||||||
res = sqlite3_bind_text16(d->stmt, i + 1, str.utf16(),
|
res = sqlite3_bind_text16(d->stmt, i + 1, str.data(),
|
||||||
int(str.size() * sizeof(ushort)),
|
int(str.size() * sizeof(ushort)),
|
||||||
SQLITE_TRANSIENT);
|
SQLITE_TRANSIENT);
|
||||||
break;
|
break;
|
||||||
@ -545,9 +545,9 @@ bool QSQLiteResult::exec()
|
|||||||
SQLITE_STATIC);
|
SQLITE_STATIC);
|
||||||
break; }
|
break; }
|
||||||
default: {
|
default: {
|
||||||
QString str = value.toString();
|
const QString str = value.toString();
|
||||||
// SQLITE_TRANSIENT makes sure that sqlite buffers the data
|
// SQLITE_TRANSIENT makes sure that sqlite buffers the data
|
||||||
res = sqlite3_bind_text16(d->stmt, i + 1, str.utf16(),
|
res = sqlite3_bind_text16(d->stmt, i + 1, str.data(),
|
||||||
int(str.size()) * sizeof(QChar),
|
int(str.size()) * sizeof(QChar),
|
||||||
SQLITE_TRANSIENT);
|
SQLITE_TRANSIENT);
|
||||||
break; }
|
break; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user