summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qelapsedtimer.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-01-30 20:53:35 +0100
committerMarc Mutz <marc.mutz@kdab.com>2015-03-14 20:31:53 +0000
commitfd76e02e9504f829871228c6c8cbdda84701dd3e (patch)
treeb54592ad7943575b3e0c149141826d41841fd4ec /src/corelib/tools/qelapsedtimer.cpp
parent748abf9347c03743d0c50b6b4d94765154158dac (diff)
QString: further optimize multiArg
This improves the previous algorithm in two aspects: 1. It parses the format string in a single pass instead of two, as was previously the case, storing all the information the result construction pass needs in a pair<QStringRef, int>. This alone would slow the algorithm down, but without it, it's hard to make the following work: 2. It avoids reallocations by calculating the size of the result and using the Qt::Uninitialized QString ctor. This speeds up the following test case QString str("%1 %2 %3 %4 %5 %6 %7 %8 %9 foo %10 %11 bar"); // not timed // (arguments converted to QString outside loop) str = str.arg("one", "2", "3", "4", "5", "6", "7", "8", "9"); str = str.arg("ahoy", "there"); from tst_qstring, which heavily favors the previous result construction loop due to the tiny (but non-zero) amount of verbatim text in between placeholders, by 25%: Qt 5.4: 1.50µs no map: 0.77µs (7b5ba56b0ab55fcaf79fbf9aad70bf767c938e15) this change: 0.58µs Change-Id: I41ec86b7a21b4b25b3bc669ff2e3b2cc73513597 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qelapsedtimer.cpp')
0 files changed, 0 insertions, 0 deletions