From ca9ed9619f1c21ba0b3ef7687bbbad9eaf2bd39a Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Sat, 9 Jul 2016 12:53:53 +0200 Subject: Improve performance of Qt::mightBeRichText by using QStringRef I noted this taking around 1% of QtQuick Text creation with a few simple bindings which is quite considerable, so hopefully improvements here will add up gradually. Also add a benchmark measuring changes: Test | From | To | Details +--------------------------------------+----------------+----------------+-----------------------+ mightBeRichText:br-invalidspace | 14466.00 instr | 10563.00 instr | -26.98% FASTER! :) mightBeRichText:br-nospace | 18581.00 instr | 14635.00 instr | -21.24% FASTER! :) mightBeRichText:br-space | 18470.00 instr | 14377.00 instr | -22.16% FASTER! :) mightBeRichText:documentation-header | 16336.00 instr | 12992.00 instr | -20.47% FASTER! :) mightBeRichText:empty | 2618.00 instr | 2618.00 instr | more or less the same mightBeRichText:invalid closing tag | 11102.00 instr | 7159.00 instr | -35.52% FASTER! :) mightBeRichText:no tags | 12503.00 instr | 8581.00 instr | -31.37% FASTER! :) mightBeRichText:simple | 17316.00 instr | 14074.00 instr | -18.72% FASTER! :) mightBeRichText:simple2 | 14394.00 instr | 10745.00 instr | -25.35% FASTER! :) +--------------------------------------+----------------+----------------+-----------------------+ Overall result | -201.81% :) Change-Id: I1817a69959d176b381bcbf27b72bb751885c3e9b Reviewed-by: Konstantin Ritt Reviewed-by: Marc Mutz Reviewed-by: Simon Hausmann --- src/gui/text/qtextdocument.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index a3dbf455cf..75899dec80 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -94,7 +94,7 @@ bool Qt::mightBeRichText(const QString& text) ++start; // skip a leading as for example with xhtml - if (text.mid(start, 5) == QLatin1String(" ++open; } -- cgit v1.2.3