summaryrefslogtreecommitdiff
path: root/src/plugins/git/gerrit/authenticationdialog.cpp
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2017-03-02 08:36:28 +0200
committerOrgad Shaneh <orgads@gmail.com>2017-03-02 10:45:53 +0000
commitd32f53e176c0c1bd3ed17b131a32336dfd59b98f (patch)
treeac6a9eb135177f988135275bee3d1439ae36a542 /src/plugins/git/gerrit/authenticationdialog.cpp
parentf2b8e9acd1c710fa2e24bf5b73d36041893041f0 (diff)
downloadqt-creator-d32f53e176c0c1bd3ed17b131a32336dfd59b98f.tar.gz
Gerrit: De-duplicate regular expression matching
Change-Id: I2bc3b2d5261153231204550634ece45d1038e5d9 Reviewed-by: André Hartmann <aha_1980@gmx.de>
Diffstat (limited to 'src/plugins/git/gerrit/authenticationdialog.cpp')
-rw-r--r--src/plugins/git/gerrit/authenticationdialog.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/plugins/git/gerrit/authenticationdialog.cpp b/src/plugins/git/gerrit/authenticationdialog.cpp
index c51b47bbc0..435177802f 100644
--- a/src/plugins/git/gerrit/authenticationdialog.cpp
+++ b/src/plugins/git/gerrit/authenticationdialog.cpp
@@ -40,10 +40,15 @@
namespace Gerrit {
namespace Internal {
-static QString findEntry(const QString &line, const QString &type)
+static QRegularExpressionMatch entryMatch(const QString &line, const QString &type)
{
const QRegularExpression regexp("(?:^|\\s)" + type + "\\s(\\S+)");
- const QRegularExpressionMatch match = regexp.match(line);
+ return regexp.match(line);
+}
+
+static QString findEntry(const QString &line, const QString &type)
+{
+ const QRegularExpressionMatch match = entryMatch(line, type);
if (match.hasMatch())
return match.captured(1);
return QString();
@@ -51,8 +56,7 @@ static QString findEntry(const QString &line, const QString &type)
static bool replaceEntry(QString &line, const QString &type, const QString &value)
{
- const QRegularExpression regexp("(?:^|\\s)" + type + "\\s(\\S+)");
- const QRegularExpressionMatch match = regexp.match(line);
+ const QRegularExpressionMatch match = entryMatch(line, type);
if (!match.hasMatch())
return false;
line.replace(match.capturedStart(1), match.capturedLength(1), value);