summaryrefslogtreecommitdiffstats
path: root/src/corelib/text
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/text')
-rw-r--r--src/corelib/text/qbytearray.cpp12
-rw-r--r--src/corelib/text/qlocale.qdoc2
-rw-r--r--src/corelib/text/qstring.cpp4
-rw-r--r--src/corelib/text/qstringiterator_p.h13
4 files changed, 20 insertions, 11 deletions
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp
index 9a72df58d3..b59979664c 100644
--- a/src/corelib/text/qbytearray.cpp
+++ b/src/corelib/text/qbytearray.cpp
@@ -1274,7 +1274,7 @@ QByteArray &QByteArray::operator=(const char *str)
functions that expect '\\0'-terminated strings. If the QByteArray object
was created from a \l{fromRawData()}{raw data} that didn't include the
trailing null-termination character then QByteArray doesn't add it
- automaticall unless the \l{deep copy} is created.
+ automatically unless the \l{deep copy} is created.
Example:
\snippet code/src_corelib_tools_qbytearray.cpp 6
@@ -4148,19 +4148,21 @@ QByteArray QByteArray::toBase64(Base64Options options) const
const char padchar = '=';
int padlen = 0;
- QByteArray tmp((d->size + 2) / 3 * 4, Qt::Uninitialized);
+ const int sz = size();
+
+ QByteArray tmp((sz + 2) / 3 * 4, Qt::Uninitialized);
int i = 0;
char *out = tmp.data();
- while (i < d->size) {
+ while (i < sz) {
// encode 3 bytes at a time
int chunk = 0;
chunk |= int(uchar(d->data()[i++])) << 16;
- if (i == d->size) {
+ if (i == sz) {
padlen = 2;
} else {
chunk |= int(uchar(d->data()[i++])) << 8;
- if (i == d->size)
+ if (i == sz)
padlen = 1;
else
chunk |= int(uchar(data()[i++]));
diff --git a/src/corelib/text/qlocale.qdoc b/src/corelib/text/qlocale.qdoc
index 49ac2a7852..0245fc9d56 100644
--- a/src/corelib/text/qlocale.qdoc
+++ b/src/corelib/text/qlocale.qdoc
@@ -1108,7 +1108,7 @@
\value MeasurementSystem a QLocale::MeasurementSystem enum specifying the measurement system
\value AMText a string that represents the system AM designator associated with a 12-hour clock.
\value PMText a string that represents the system PM designator associated with a 12-hour clock.
- \value FirstDayOfWeek a Qt::DayOfWeek enum specifiying the first day of the week
+ \value FirstDayOfWeek a Qt::DayOfWeek enum specifying the first day of the week
\value CurrencySymbol a string that represents a currency in a format QLocale::CurrencyFormat.
\value CurrencyToString a localized string representation of a number with a currency symbol. Converts a QSystemLocale::CurrencyToStringArgument stored in the in variant to a QString.
\value UILanguages a list of strings representing locale names that could be used for UI translation.
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index 8deeae47bb..72de9adf17 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -647,6 +647,8 @@ void qt_from_latin1(ushort *dst, const char *str, size_t size) noexcept
# endif
#endif
#if defined(__mips_dsp)
+ static_assert(sizeof(qsizetype) == sizeof(int),
+ "oops, the assembler implementation needs to be called in a loop");
if (size > 20)
qt_fromlatin1_mips_asm_unroll8(dst, str, size);
else
@@ -802,6 +804,8 @@ static void qt_to_latin1_internal(uchar *dst, const ushort *src, qsizetype lengt
}
#endif
#if defined(__mips_dsp)
+ static_assert(sizeof(qsizetype) == sizeof(int),
+ "oops, the assembler implementation needs to be called in a loop");
qt_toLatin1_mips_dsp_asm(dst, src, length);
#else
while (length--) {
diff --git a/src/corelib/text/qstringiterator_p.h b/src/corelib/text/qstringiterator_p.h
index 219589b6e4..b31c7673c2 100644
--- a/src/corelib/text/qstringiterator_p.h
+++ b/src/corelib/text/qstringiterator_p.h
@@ -61,6 +61,8 @@ class QStringIterator
{
QString::const_iterator i, pos, e;
Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
+ static bool less(const QChar *lhs, const QChar *rhs) noexcept
+ { return std::less<const QChar *>{}(lhs, rhs); }
public:
explicit QStringIterator(QStringView string, qsizetype idx = 0)
: i(string.begin()),
@@ -95,7 +97,8 @@ public:
inline void setPosition(QString::const_iterator position)
{
- Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
+ Q_ASSERT_X(!less(position, i) && !less(e, position),
+ Q_FUNC_INFO, "position out of bounds");
pos = position;
}
@@ -103,7 +106,7 @@ public:
inline bool hasNext() const
{
- return pos < e;
+ return less(pos, e);
}
inline void advance()
@@ -166,7 +169,7 @@ public:
const QChar uc = *pos++;
if (Q_UNLIKELY(uc.isSurrogate())) {
- if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
+ if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
return QChar::surrogateToUcs4(uc, *pos++);
return invalidAs;
}
@@ -178,7 +181,7 @@ public:
inline bool hasPrevious() const
{
- return pos > i;
+ return less(i, pos);
}
inline void recede()
@@ -241,7 +244,7 @@ public:
const QChar uc = *--pos;
if (Q_UNLIKELY(uc.isSurrogate())) {
- if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
+ if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
return QChar::surrogateToUcs4(*--pos, uc);
return invalidAs;
}