Skip to content

Commit bb86997

Browse files
committed
XboardEngine: use QStringView in parseFeatures
This is a continuation of the previous work to move protocol parsing to QStringView based API.
1 parent e461e36 commit bb86997

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

projects/lib/src/xboardengine.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -717,8 +717,7 @@ void XboardEngine::parseLine(const QString& line)
717717
}
718718
else if (command == QLatin1String("feature"))
719719
{
720-
// XXX: parseFeatures() should use QStringView
721-
for (const XboardFeature& feature : parseFeatures(args.toString())) {
720+
for (const XboardFeature& feature : parseFeatures(args)) {
722721
setFeature(feature.first, feature.second);
723722
}
724723
}
@@ -759,10 +758,12 @@ void XboardEngine::sendOption(const QString& name, const QVariant& value)
759758
}
760759
}
761760

762-
QList<XboardFeature> XboardEngine::parseFeatures(const QString& featureArgs)
761+
QList<XboardFeature> XboardEngine::parseFeatures(QStringView featureArgs)
763762
{
764763
QList<XboardFeature> features;
765764
QRegularExpression re("(\\w+)\\s*=\\s*(\"[^\"]+\"|\\w+)");
765+
// XXX: use QRegularExpression::globalMatchView() on Qt 6.5+ and
766+
// make a copy of the string only on `features.append(...)`
766767
auto i = re.globalMatch(featureArgs);
767768

768769
while (i.hasNext())

projects/lib/src/xboardengine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class LIB_EXPORT XboardEngine : public ChessEngine
5656
virtual bool restartsBetweenGames() const;
5757

5858
/*! Parses a feature string from the engine. */
59-
QList<XboardFeature> parseFeatures(const QString& featureArgs);
59+
QList<XboardFeature> parseFeatures(QStringView featureArgs);
6060

6161
/*! Parses a principal valuation string from the engine. */
6262
MoveEvaluation parsePv(QStringView pvString);

0 commit comments

Comments
 (0)