summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-10-15 14:37:31 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-10-19 00:47:19 +0200
commit79917d79656d3a217ca4f9a4c24a6d87c5ebc06a (patch)
tree4ecb13b738625cdc5e5a5036e2b8bc325b358164 /src/corelib
parent927cd268aac8e1a97a127f63b9dd83e831c8b642 (diff)
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>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/text/qregularexpression.cpp5
-rw-r--r--src/corelib/text/qregularexpression.h4
2 files changed, 4 insertions, 5 deletions
diff --git a/src/corelib/text/qregularexpression.cpp b/src/corelib/text/qregularexpression.cpp
index 45ed3f806a..cd5cd53c55 100644
--- a/src/corelib/text/qregularexpression.cpp
+++ b/src/corelib/text/qregularexpression.cpp
@@ -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());
}
/*!
diff --git a/src/corelib/text/qregularexpression.h b/src/corelib/text/qregularexpression.h
index efa9470685..b33c44020f 100644
--- a/src/corelib/text/qregularexpression.h
+++ b/src/corelib/text/qregularexpression.h
@@ -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 {