summaryrefslogtreecommitdiffstats
path: root/src/corelib/text
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/text')
-rw-r--r--src/corelib/text/qchar.cpp6
-rw-r--r--src/corelib/text/qlocale.cpp6
-rw-r--r--src/corelib/text/qstring.cpp50
-rw-r--r--src/corelib/text/qstring.h20
-rw-r--r--src/corelib/text/qstringconverter.cpp14
-rw-r--r--src/corelib/text/qstringlist.cpp4
-rw-r--r--src/corelib/text/qtextboundaryfinder.cpp2
7 files changed, 51 insertions, 51 deletions
diff --git a/src/corelib/text/qchar.cpp b/src/corelib/text/qchar.cpp
index a9cf306dd9d..272de292c5e 100644
--- a/src/corelib/text/qchar.cpp
+++ b/src/corelib/text/qchar.cpp
@@ -2061,7 +2061,7 @@ static bool normalizationQuickCheckHelper(QString *str, QString::NormalizationFo
enum { NFQC_YES = 0, NFQC_NO = 1, NFQC_MAYBE = 3 };
const ushort *string = reinterpret_cast<const ushort *>(str->constData());
- qsizetype length = str->length();
+ qsizetype length = str->size();
// this avoids one out of bounds check in the loop
while (length > from && QChar::isHighSurrogate(string[length - 1]))
@@ -2104,8 +2104,8 @@ static bool normalizationQuickCheckHelper(QString *str, QString::NormalizationFo
*lastStable = pos;
}
- if (length != str->length()) // low surrogate parts at the end of text
- *lastStable = str->length() - 1;
+ if (length != str->size()) // low surrogate parts at the end of text
+ *lastStable = str->size() - 1;
return true;
}
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp
index 031ba74fac0..bd41f7ea5bc 100644
--- a/src/corelib/text/qlocale.cpp
+++ b/src/corelib/text/qlocale.cpp
@@ -555,7 +555,7 @@ static bool isScript(QStringView tag)
static const QString allScripts =
QString::fromLatin1(reinterpret_cast<const char *>(script_code_list),
sizeof(script_code_list) - 1);
- return tag.length() == 4 && allScripts.indexOf(tag) % 4 == 0;
+ return tag.size() == 4 && allScripts.indexOf(tag) % 4 == 0;
}
bool qt_splitLocaleName(QStringView name, QStringView *lang, QStringView *script, QStringView *land)
@@ -4014,7 +4014,7 @@ bool QLocaleData::validateChars(QStringView str, NumberMode numMode, QByteArray
int decDigits, QLocale::NumberOptions number_options) const
{
buff->clear();
- buff->reserve(str.length());
+ buff->reserve(str.size());
enum { Whole, Fractional, Exponent } state = Whole;
const bool scientific = numMode == DoubleScientificMode;
@@ -4110,7 +4110,7 @@ double QLocaleData::stringToDouble(QStringView str, bool *ok,
}
int processed = 0;
bool nonNullOk = false;
- double d = qt_asciiToDouble(buff.constData(), buff.length() - 1, nonNullOk, processed);
+ double d = qt_asciiToDouble(buff.constData(), buff.size() - 1, nonNullOk, processed);
if (ok != nullptr)
*ok = nonNullOk;
return d;
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index 2372a5cb0ba..79ab557e811 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -2718,9 +2718,9 @@ void QString::resize(qsizetype size)
void QString::resize(qsizetype newSize, QChar fillChar)
{
- const qsizetype oldSize = length();
+ const qsizetype oldSize = size();
resize(newSize);
- const qsizetype difference = length() - oldSize;
+ const qsizetype difference = size() - oldSize;
if (difference > 0)
std::fill_n(d.data() + oldSize, difference, fillChar.unicode());
}
@@ -4188,7 +4188,7 @@ QString &QString::replace(QChar c, QLatin1StringView after, Qt::CaseSensitivity
*/
qsizetype QString::indexOf(const QString &str, qsizetype from, Qt::CaseSensitivity cs) const
{
- return QtPrivate::findString(QStringView(unicode(), length()), from, QStringView(str.unicode(), str.size()), cs);
+ return QtPrivate::findString(QStringView(unicode(), size()), from, QStringView(str.unicode(), str.size()), cs);
}
/*!
@@ -4242,7 +4242,7 @@ qsizetype QString::indexOf(QLatin1StringView str, qsizetype from, Qt::CaseSensit
*/
qsizetype QString::indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const
{
- return qFindChar(QStringView(unicode(), length()), ch, from, cs);
+ return qFindChar(QStringView(unicode(), size()), ch, from, cs);
}
/*!
@@ -4506,7 +4506,7 @@ QString &QString::replace(const QRegularExpression &re, const QString &after)
}
// add the last part of the after string
- len = afterView.length() - lastEnd;
+ len = afterView.size() - lastEnd;
if (len > 0) {
chunks << afterView.mid(lastEnd, len);
newLength += len;
@@ -4516,9 +4516,9 @@ QString &QString::replace(const QRegularExpression &re, const QString &after)
}
// 3. trailing string after the last match
- if (copyView.length() > lastEnd) {
+ if (copyView.size() > lastEnd) {
chunks << copyView.mid(lastEnd);
- newLength += copyView.length() - lastEnd;
+ newLength += copyView.size() - lastEnd;
}
// 4. assemble the chunks together
@@ -4526,7 +4526,7 @@ QString &QString::replace(const QRegularExpression &re, const QString &after)
qsizetype i = 0;
QChar *uc = data();
for (const QStringView &chunk : std::as_const(chunks)) {
- qsizetype len = chunk.length();
+ qsizetype len = chunk.size();
memcpy(uc + i, chunk.constData(), len * sizeof(QChar));
i += len;
}
@@ -4889,7 +4889,7 @@ static QString extractSections(const QList<qt_section_chunk> &sections, qsizetyp
qsizetype skip = 0;
for (qsizetype k = 0; k < sectionsSize; ++k) {
const qt_section_chunk &section = sections.at(k);
- if (section.length == section.string.length())
+ if (section.length == section.string.size())
skip++;
}
if (start < 0)
@@ -4905,7 +4905,7 @@ static QString extractSections(const QList<qt_section_chunk> &sections, qsizetyp
qsizetype first_i = start, last_i = end;
for (qsizetype i = 0; x <= end && i < sectionsSize; ++i) {
const qt_section_chunk &section = sections.at(i);
- const bool empty = (section.length == section.string.length());
+ const bool empty = (section.length == section.string.size());
if (x >= start) {
if (x == start)
first_i = i;
@@ -4964,7 +4964,7 @@ QString QString::section(const QRegularExpression &re, qsizetype start, qsizetyp
sep.setPatternOptions(sep.patternOptions() | QRegularExpression::CaseInsensitiveOption);
QList<qt_section_chunk> sections;
- qsizetype n = length(), m = 0, last_m = 0, last_len = 0;
+ qsizetype n = size(), m = 0, last_m = 0, last_len = 0;
QRegularExpressionMatchIterator iterator = sep.globalMatch(*this);
while (iterator.hasNext()) {
QRegularExpressionMatch match = iterator.next();
@@ -5321,7 +5321,7 @@ static QByteArray qt_convert_to_latin1(QStringView string)
if (Q_UNLIKELY(string.isNull()))
return QByteArray();
- QByteArray ba(string.length(), Qt::Uninitialized);
+ QByteArray ba(string.size(), Qt::Uninitialized);
// since we own the only copy, we're going to const_cast the constData;
// that avoids an unnecessary call to detach() and expansion code that will never get used
@@ -5490,7 +5490,7 @@ QList<uint> QString::toUcs4() const
static QList<uint> qt_convert_to_ucs4(QStringView string)
{
- QList<uint> v(string.length());
+ QList<uint> v(string.size());
uint *a = const_cast<uint*>(v.constData());
QStringIterator it(string);
while (it.hasNext())
@@ -6445,7 +6445,7 @@ int QLatin1StringView::compare_helper(const QChar *data1, qsizetype length1, QLa
*/
int QString::localeAwareCompare(const QString &other) const
{
- return localeAwareCompare_helper(constData(), length(), other.constData(), other.size());
+ return localeAwareCompare_helper(constData(), size(), other.constData(), other.size());
}
/*!
@@ -6561,7 +6561,7 @@ const ushort *QString::utf16() const
QString QString::leftJustified(qsizetype width, QChar fill, bool truncate) const
{
QString result;
- qsizetype len = length();
+ qsizetype len = size();
qsizetype padlen = width - len;
if (padlen > 0) {
result.resize(len+padlen);
@@ -6600,7 +6600,7 @@ QString QString::leftJustified(qsizetype width, QChar fill, bool truncate) const
QString QString::rightJustified(qsizetype width, QChar fill, bool truncate) const
{
QString result;
- qsizetype len = length();
+ qsizetype len = size();
qsizetype padlen = width - len;
if (padlen > 0) {
result.resize(len+padlen);
@@ -7933,7 +7933,7 @@ void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar::
// check if it's fully ASCII first, because then we have no work
auto start = reinterpret_cast<const char16_t *>(data->constData());
const char16_t *p = start + from;
- if (isAscii_helper(p, p + data->length() - from))
+ if (isAscii_helper(p, p + data->size() - from))
return;
if (p > start + from)
from = p - start - 1; // need one before the non-ASCII to perform NFC
@@ -8119,9 +8119,9 @@ static QString replaceArgEscapes(QStringView s, const ArgEscapeData &d, qsizetyp
// Negative field-width for right-padding, positive for left-padding:
const qsizetype abs_field_width = qAbs(field_width);
const qsizetype result_len =
- s.length() - d.escape_len
- + (d.occurrences - d.locale_occurrences) * qMax(abs_field_width, arg.length())
- + d.locale_occurrences * qMax(abs_field_width, larg.length());
+ s.size() - d.escape_len
+ + (d.occurrences - d.locale_occurrences) * qMax(abs_field_width, arg.size())
+ + d.locale_occurrences * qMax(abs_field_width, larg.size());
QString result(result_len, Qt::Uninitialized);
QChar *rc = const_cast<QChar *>(result.unicode());
@@ -8164,15 +8164,15 @@ static QString replaceArgEscapes(QStringView s, const ArgEscapeData &d, qsizetyp
rc += escape_start - text_start;
const QStringView use = localize ? larg : arg;
- const qsizetype pad_chars = abs_field_width - use.length();
+ const qsizetype pad_chars = abs_field_width - use.size();
// (If negative, relevant loops are no-ops: no need to check.)
if (field_width > 0) { // left padded
rc = std::fill_n(rc, pad_chars, fillChar);
}
- memcpy(rc, use.data(), use.length() * sizeof(QChar));
- rc += use.length();
+ memcpy(rc, use.data(), use.size() * sizeof(QChar));
+ rc += use.size();
if (field_width < 0) { // right padded
rc = std::fill_n(rc, pad_chars, fillChar);
@@ -10956,7 +10956,7 @@ qsizetype QtPrivate::count(QStringView haystack, const QRegularExpression &re)
}
qsizetype count = 0;
qsizetype index = -1;
- qsizetype len = haystack.length();
+ qsizetype len = haystack.size();
while (index <= len - 1) {
QRegularExpressionMatch match = re.matchView(haystack, index + 1);
if (!match.hasMatch())
@@ -10983,7 +10983,7 @@ qsizetype QtPrivate::count(QStringView haystack, const QRegularExpression &re)
QString QString::toHtmlEscaped() const
{
QString rich;
- const qsizetype len = length();
+ const qsizetype len = size();
rich.reserve(qsizetype(len * 1.1));
for (QChar ch : *this) {
if (ch == u'<')
diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h
index 9c67558edd8..300b54feb65 100644
--- a/src/corelib/text/qstring.h
+++ b/src/corelib/text/qstring.h
@@ -679,19 +679,19 @@ public:
QString &insert(qsizetype i, QChar c);
QString &insert(qsizetype i, const QChar *uc, qsizetype len);
inline QString &insert(qsizetype i, const QString &s) { return insert(i, s.constData(), s.size()); }
- inline QString &insert(qsizetype i, QStringView v) { return insert(i, v.data(), v.length()); }
+ inline QString &insert(qsizetype i, QStringView v) { return insert(i, v.data(), v.size()); }
QString &insert(qsizetype i, QLatin1StringView s);
QString &append(QChar c);
QString &append(const QChar *uc, qsizetype len);
QString &append(const QString &s);
- inline QString &append(QStringView v) { return append(v.data(), v.length()); }
+ inline QString &append(QStringView v) { return append(v.data(), v.size()); }
QString &append(QLatin1StringView s);
inline QString &prepend(QChar c) { return insert(0, c); }
inline QString &prepend(const QChar *uc, qsizetype len) { return insert(0, uc, len); }
inline QString &prepend(const QString &s) { return insert(0, s); }
- inline QString &prepend(QStringView v) { return prepend(v.data(), v.length()); }
+ inline QString &prepend(QStringView v) { return prepend(v.data(), v.size()); }
inline QString &prepend(QLatin1StringView s) { return insert(0, s); }
inline QString &operator+=(QChar c) { return append(c); }
@@ -1193,7 +1193,7 @@ QString QLatin1StringView::toString() const { return *this; }
//
QString QStringView::toString() const
-{ return Q_ASSERT(size() == length()), QString(data(), length()); }
+{ return Q_ASSERT(size() == size()), QString(data(), size()); }
qint64 QStringView::toLongLong(bool *ok, int base) const
{ return QString::toIntegral_helper<qint64>(*this, ok, base); }
@@ -1483,7 +1483,7 @@ inline QString QString::fromStdString(const std::string &s)
inline std::wstring QString::toStdWString() const
{
std::wstring str;
- str.resize(length());
+ str.resize(size());
str.resize(toWCharArray(str.data()));
return str;
}
@@ -1495,16 +1495,16 @@ inline QString QString::fromStdU16String(const std::u16string &s)
{ return fromUtf16(s.data(), qsizetype(s.size())); }
inline std::u16string QString::toStdU16String() const
-{ return std::u16string(reinterpret_cast<const char16_t*>(data()), length()); }
+{ return std::u16string(reinterpret_cast<const char16_t*>(data()), size()); }
inline QString QString::fromStdU32String(const std::u32string &s)
{ return fromUcs4(s.data(), qsizetype(s.size())); }
inline std::u32string QString::toStdU32String() const
{
- std::u32string u32str(length(), char32_t(0));
+ std::u32string u32str(size(), char32_t(0));
qsizetype len = toUcs4_helper(reinterpret_cast<const ushort *>(constData()),
- length(), reinterpret_cast<uint*>(&u32str[0]));
+ size(), reinterpret_cast<uint*>(&u32str[0]));
u32str.resize(len);
return u32str;
}
@@ -1521,9 +1521,9 @@ inline int QString::compare(QStringView s, Qt::CaseSensitivity cs) const noexcep
{ return -s.compare(*this, cs); }
inline int QString::localeAwareCompare(QStringView s) const
-{ return localeAwareCompare_helper(constData(), length(), s.constData(), s.length()); }
+{ return localeAwareCompare_helper(constData(), size(), s.constData(), s.size()); }
inline int QString::localeAwareCompare(QStringView s1, QStringView s2)
-{ return localeAwareCompare_helper(s1.constData(), s1.length(), s2.constData(), s2.length()); }
+{ return localeAwareCompare_helper(s1.constData(), s1.size(), s2.constData(), s2.size()); }
inline int QStringView::localeAwareCompare(QStringView other) const
{ return QString::localeAwareCompare(*this, other); }
diff --git a/src/corelib/text/qstringconverter.cpp b/src/corelib/text/qstringconverter.cpp
index a0e0173cbb1..bdba20de3ac 100644
--- a/src/corelib/text/qstringconverter.cpp
+++ b/src/corelib/text/qstringconverter.cpp
@@ -504,7 +504,7 @@ char *QUtf8::convertFromUnicode(char *out, QStringView in, QStringConverter::Sta
{
Q_ASSERT(state);
const QChar *uc = in.data();
- qsizetype len = in.length();
+ qsizetype len = in.size();
if (!len)
return out;
@@ -915,13 +915,13 @@ char *QUtf16::convertFromUnicode(char *out, QStringView in, QStringConverter::St
out += 2;
}
if (endian == BigEndianness)
- qToBigEndian<char16_t>(in.data(), in.length(), out);
+ qToBigEndian<char16_t>(in.data(), in.size(), out);
else
- qToLittleEndian<char16_t>(in.data(), in.length(), out);
+ qToLittleEndian<char16_t>(in.data(), in.size(), out);
state->remainingChars = 0;
state->internalState |= HeaderDone;
- return out + 2*in.length();
+ return out + 2*in.size();
}
QString QUtf16::convertToUnicode(QByteArrayView in, QStringConverter::State *state, DataEndianness endian)
@@ -1051,7 +1051,7 @@ char *QUtf32::convertFromUnicode(char *out, QStringView in, QStringConverter::St
}
const QChar *uc = in.data();
- const QChar *end = in.data() + in.length();
+ const QChar *end = in.data() + in.size();
QChar ch;
char32_t ucs4;
if (state->remainingChars == 1) {
@@ -1489,7 +1489,7 @@ static char *toLatin1(char *out, QStringView in, QStringConverter::State *state)
const char replacement = (state && state->flags & QStringConverter::Flag::ConvertInvalidToNull) ? 0 : '?';
qsizetype invalid = 0;
- for (qsizetype i = 0; i < in.length(); ++i) {
+ for (qsizetype i = 0; i < in.size(); ++i) {
if (in[i] > QChar(0xff)) {
*out = replacement;
++invalid;
@@ -1765,7 +1765,7 @@ struct QStringConverterICU : QStringConverter
auto source = reinterpret_cast<const UChar *>(in.data());
auto sourceLimit = reinterpret_cast<const UChar *>(in.data() + in.size());
- qsizetype length = UCNV_GET_MAX_BYTES_FOR_STRING(in.length(), ucnv_getMaxCharSize(icu_conv));
+ qsizetype length = UCNV_GET_MAX_BYTES_FOR_STRING(in.size(), ucnv_getMaxCharSize(icu_conv));
char *target = out;
char *targetLimit = out + length;
diff --git a/src/corelib/text/qstringlist.cpp b/src/corelib/text/qstringlist.cpp
index 8eb730ee02a..2c0dc77a5a0 100644
--- a/src/corelib/text/qstringlist.cpp
+++ b/src/corelib/text/qstringlist.cpp
@@ -387,7 +387,7 @@ void QtPrivate::QStringList_replaceInStrings(QStringList *that, QStringView befo
QStringView after, Qt::CaseSensitivity cs)
{
for (qsizetype i = 0; i < that->size(); ++i)
- (*that)[i].replace(before.data(), before.length(), after.data(), after.length(), cs);
+ (*that)[i].replace(before.data(), before.size(), after.data(), after.size(), cs);
}
#if QT_CONFIG(regularexpression)
@@ -492,7 +492,7 @@ QString QtPrivate::QStringList_join(const QStringList &list, QLatin1StringView s
*/
QString QtPrivate::QStringList_join(const QStringList *that, QStringView sep)
{
- return QStringList_join(that, sep.data(), sep.length());
+ return QStringList_join(that, sep.data(), sep.size());
}
/*!
diff --git a/src/corelib/text/qtextboundaryfinder.cpp b/src/corelib/text/qtextboundaryfinder.cpp
index 937f88b2525..8f20967a1d7 100644
--- a/src/corelib/text/qtextboundaryfinder.cpp
+++ b/src/corelib/text/qtextboundaryfinder.cpp
@@ -20,7 +20,7 @@ static void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharA
case QTextBoundaryFinder::Line: options |= QUnicodeTools::LineBreaks; break;
default: break;
}
- QUnicodeTools::initCharAttributes(str, scriptItems.data(), scriptItems.count(), attributes, options);
+ QUnicodeTools::initCharAttributes(str, scriptItems.data(), scriptItems.size(), attributes, options);
}
/*!