Replace some QString::fromRawData() with QStringViews around the code
Even though QString::fromRawData() may not be as expensive as it used to be, it's still and out-of-line call _and_ more characters to type, so replace with QStringView construction where applicable. Change-Id: I70662da1bd45284f67e117e92b25d242afb8aaf8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
bed25fdf60
commit
5bd7668403
@ -1210,7 +1210,7 @@ static const QChar *parseIpFuture(QString &host, const QChar *begin, const QChar
|
||||
(begin[2].unicode() >= '0' && begin[2].unicode() <= '9')) {
|
||||
// this is so unlikely that we'll just go down the slow path
|
||||
// decode the whole string, skipping the "[vH." and "]" which we already know to be there
|
||||
host += QString::fromRawData(begin, 4);
|
||||
host += QStringView(begin, 4);
|
||||
|
||||
// uppercase the version, if necessary
|
||||
if (begin[2].unicode() >= 'a')
|
||||
|
@ -193,7 +193,7 @@ QDebug operator<<(QDebug dbg, CFStringRef stringRef)
|
||||
return dbg << "CFStringRef(0x0)";
|
||||
|
||||
if (const UniChar *chars = CFStringGetCharactersPtr(stringRef))
|
||||
dbg << QString::fromRawData(reinterpret_cast<const QChar *>(chars), CFStringGetLength(stringRef));
|
||||
dbg << QStringView(reinterpret_cast<const QChar *>(chars), CFStringGetLength(stringRef));
|
||||
else
|
||||
dbg << QString::fromCFString(stringRef);
|
||||
|
||||
|
@ -3156,7 +3156,7 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
|
||||
#ifdef QT_DEBUG_DRAW
|
||||
Q_D(QRasterPaintEngine);
|
||||
fprintf(stderr," - QRasterPaintEngine::drawTextItem(), (%.2f,%.2f), string=%s ct=%d\n",
|
||||
p.x(), p.y(), QString::fromRawData(ti.chars, ti.num_chars).toLatin1().data(),
|
||||
p.x(), p.y(), QStringView(ti.chars, ti.num_chars).toLatin1().data(),
|
||||
d->glyphCacheFormat);
|
||||
#endif
|
||||
|
||||
|
@ -1219,7 +1219,7 @@ QString QTextBlock::text() const
|
||||
QTextDocumentPrivate::FragmentIterator end = p->find(pos + length() - 1); // -1 to omit the block separator char
|
||||
for (; it != end; ++it) {
|
||||
const QTextFragmentData * const frag = it.value();
|
||||
text += QString::fromRawData(buffer.constData() + frag->stringPosition, frag->size_array[0]);
|
||||
text += QStringView(buffer.constData() + frag->stringPosition, frag->size_array[0]);
|
||||
}
|
||||
|
||||
return text;
|
||||
|
Loading…
Reference in New Issue
Block a user