Port QStringIterator to qsizetype

Most of the API is formulated using iterators, but index() and one of
the ctors still used int.

Patch users. There appear to be no users of this class outside of
QtBase.

Pick-to: 6.4 6.3 6.2
Task-number: QTBUG-103531
Change-Id: I097ce839d74ff76bd8c1925d09634ffeaaa2fc07
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Marc Mutz 2022-07-20 15:32:40 +02:00
parent 34800d1f09
commit 4ed2c92bf4
2 changed files with 8 additions and 8 deletions

View File

@ -128,13 +128,13 @@ static QString macZeroDigit()
return QString::fromCFString(value);
}
static QString zeroPad(QString &&number, int minDigits, const QString &zero)
static QString zeroPad(QString &&number, qsizetype minDigits, const QString &zero)
{
// Need to pad with zeros, possibly after a sign.
int insert = -1, digits = 0;
qsizetype insert = -1, digits = 0;
auto it = QStringIterator(number);
while (it.hasNext()) {
int here = it.index();
qsizetype here = it.index();
if (QChar::isDigit(it.next())) {
if (insert < 0)
insert = here;
@ -154,10 +154,10 @@ static QString trimTwoDigits(QString &&number)
// Retain any sign, but remove all but the last two digits.
// We know number has at least four digits - it came from fourDigitYear().
// Note that each digit might be a surrogate pair.
int first = -1, prev = -1, last = -1;
qsizetype first = -1, prev = -1, last = -1;
auto it = QStringIterator(number);
while (it.hasNext()) {
int here = it.index();
qsizetype here = it.index();
if (QChar::isDigit(it.next())) {
if (first == -1)
last = first = here;

View File

@ -40,7 +40,7 @@ public:
{
}
inline explicit QStringIterator(const QChar *begin, int idx, const QChar *end)
explicit QStringIterator(const QChar *begin, qsizetype idx, const QChar *end)
: i(begin),
pos(begin + idx),
e(end)
@ -52,9 +52,9 @@ public:
return pos;
}
inline int index() const
qsizetype index() const
{
return int(pos - i);
return pos - i;
}
inline void setPosition(QString::const_iterator position)