summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstring.cpp
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2014-08-24 09:44:42 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2014-08-24 18:23:33 +0200
commit4cd53ad3a64dedc788346979fccabd8810104b20 (patch)
tree320072d8c82fba2cf77eaeaa85e5ed30cb58a7ed /src/corelib/tools/qstring.cpp
parent4cceceff155a6d43cb0ac312d3055390cfc75201 (diff)
Refactor QString::contains(QRegularExpression)
Unify the code of the two overloads; fix a typo in a warning; and use an opportunity to insert a move. Change-Id: I85eef86d35f0d1e2da25f09d92204e32abf6d7d3 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/corelib/tools/qstring.cpp')
-rw-r--r--src/corelib/tools/qstring.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 037c7a8fe5..169b48aa5a 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -3732,12 +3732,7 @@ int QString::lastIndexOf(const QRegularExpression &re, int from) const
*/
bool QString::contains(const QRegularExpression &re) const
{
- if (!re.isValid()) {
- qWarning("QString::contains: invalid QRegularExpression object");
- return false;
- }
- QRegularExpressionMatch match = re.match(*this);
- return match.hasMatch();
+ return contains(re, Q_NULLPTR);
}
/*!
@@ -3757,13 +3752,13 @@ bool QString::contains(const QRegularExpression &re) const
bool QString::contains(const QRegularExpression &re, QRegularExpressionMatch *match) const
{
if (!re.isValid()) {
- qWarning("QString::contains: invalid QRegularExpresssion object");
+ qWarning("QString::contains: invalid QRegularExpression object");
return false;
}
QRegularExpressionMatch m = re.match(*this);
bool hasMatch = m.hasMatch();
if (hasMatch && match)
- *match = m;
+ *match = qMove(m);
return hasMatch;
}