diff options
author | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-06-02 10:53:38 +0300 |
---|---|---|
committer | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-06-02 17:20:44 +0000 |
commit | 84bd6a83a02f6357978dbf3e8b3a553a96d22772 (patch) | |
tree | c86d8726767e0773fece1e6145f2aed4dc5f4f0c /src/gui/text | |
parent | f046205526031fd42f4492ada28194cedcda1a4c (diff) |
QTextDocument: use QString::replace() for replacing
... instead of homebrew algorithm.
Saves some memory allocations and some text size.
Change-Id: I3abb49d3b247dbb132688ea99e6eae731e31615c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qtextdocument.cpp | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index bb4f031415..723918ae69 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -2700,13 +2700,8 @@ void QTextHtmlExporter::emitFragment(const QTextFragment &fragment) // split for [\n{LineSeparator}] QString forcedLineBreakRegExp = QString::fromLatin1("[\\na]"); forcedLineBreakRegExp[3] = QChar::LineSeparator; - - const QStringList lines = txt.split(QRegExp(forcedLineBreakRegExp)); - for (int i = 0; i < lines.count(); ++i) { - if (i > 0) - html += QLatin1String("<br />"); // space on purpose for compatibility with Netscape, Lynx & Co. - html += lines.at(i); - } + // space in BR on purpose for compatibility with old-fashioned browsers + html += txt.replace(QRegExp(forcedLineBreakRegExp), QLatin1String("<br />")); } if (attributesEmitted) |