QRegularExpression: port to QESDP

For QRegularExpressionMatchIterator there is actually one code
path that modifies the object itself. Avoid spurious calls to
detach() in there by making the detach explicit, and streamline
the rest of the code around it.

QRegularExpressionMatch only has a const API so it "doesn't care",
but port it for consistency.

Change-Id: I26881b3af9ae75082dd39462115869b1a9ee1339
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Giuseppe D'Angelo 2020-10-15 14:37:31 +02:00
parent 927cd268aa
commit 79917d7965
2 changed files with 4 additions and 5 deletions

View File

@ -2572,9 +2572,8 @@ QRegularExpressionMatch QRegularExpressionMatchIterator::next()
return d.constData()->next;
}
QRegularExpressionMatch current = d.constData()->next;
d->next = current.d.constData()->nextMatch();
return current;
d.detach();
return qExchange(d->next, d->next.d.constData()->nextMatch());
}
/*!

View File

@ -263,7 +263,7 @@ private:
friend class QRegularExpressionMatchIterator;
QRegularExpressionMatch(QRegularExpressionMatchPrivate &dd);
QSharedDataPointer<QRegularExpressionMatchPrivate> d;
QExplicitlySharedDataPointer<QRegularExpressionMatchPrivate> d;
};
Q_DECLARE_SHARED(QRegularExpressionMatch)
@ -308,7 +308,7 @@ private:
friend QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIteratorSentinel end(const QRegularExpressionMatchIterator &) { return {}; }
QRegularExpressionMatchIterator(QRegularExpressionMatchIteratorPrivate &dd);
QSharedDataPointer<QRegularExpressionMatchIteratorPrivate> d;
QExplicitlySharedDataPointer<QRegularExpressionMatchIteratorPrivate> d;
};
namespace QtPrivate {