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. Task-number: QTBUG-103531 Change-Id: I097ce839d74ff76bd8c1925d09634ffeaaa2fc07 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 4ed2c92bf4d46e6d4c9d8c321a35aa0bfc368fbf) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
431d508216
commit
f3e76c9cbf
@ -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;
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user