<table><tr><td style="">dhaumann added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D24982">View Revision</a></tr></table><br /><div><div><p>I wonder if the <tt style="background: #ebebeb; font-size: 13px;">?:</tt> optimizations make sense. QRegularExpression has the option <tt style="background: #ebebeb; font-size: 13px;">QRegularExpression::DontCaptureOption</tt> to not capture anything. Looking into our code we have:</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">561 bool RegExpr::doLoad(QXmlStreamReader& reader)
562 {
563 m_regexp.setPattern(reader.attributes().value(QStringLiteral("String")).toString()); // here we set the pattern -> OK
564
565 const auto isMinimal = Xml::attrToBool(reader.attributes().value(QStringLiteral("minimal")));
566 const auto isCaseInsensitive = Xml::attrToBool(reader.attributes().value(QStringLiteral("insensitive")));
567 m_regexp.setPatternOptions( // if (m_dynamic == false), we could add the
568 (isMinimal ? QRegularExpression::InvertedGreedinessOption : QRegularExpression::NoPatternOption) | // flag QRegularExpression::DontCaptureOption
569 (isCaseInsensitive ? QRegularExpression::CaseInsensitiveOption : QRegularExpression::NoPatternOption));
570
571 // optimize the pattern for the non-dynamic case, we use them OFTEN
572 m_dynamic = Xml::attrToBool(reader.attributes().value(QStringLiteral("dynamic")));
573 if (!m_dynamic) {
574 m_regexp.optimize();
575 }
576 // [...]</pre></div>
<p>In other words: The current patch adds many <tt style="background: #ebebeb; font-size: 13px;">?:</tt> which also makes the RegExps harder to read. So: Do we really get a performance gain here? Wouldn't it be possible to get an even better performance gain by using the flag <tt style="background: #ebebeb; font-size: 13px;">DontCaptureOption</tt>?</p>
<p>Currently, I am not yet convinced, can you give this a try? :-)</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R216 Syntax Highlighting</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D24982">https://phabricator.kde.org/D24982</a></div></div><br /><div><strong>To: </strong>nibags, Framework: Syntax Highlighting, dhaumann, cullmann<br /><strong>Cc: </strong>kwrite-devel, kde-frameworks-devel, LeGast00n, GB_2, domson, michaelh, ngraham, bruns, demsking, cullmann, sars, dhaumann<br /></div>