Go to file
Marc Mutz 7b5ba56b0a QString: optimize multiArg()
The function used a QMap<int,int> to map the %n's to the index
in the args array.

By way of construction, the key was sorted in ascending order
while the values, initially all -1, were later reassigned to be
0...map.size()-1, ie. std::iota().

The only information this data structure stores is therefore
the sorted %n's. For that, a sorted vector is a vastly superior
data structure.

Go one step further and use QVarLengthArray to avoid
allocating any memory for the common case of just a few
placeholders.

As an artifact of the underlying refactoring, the management
of that data structure has been moved to a separate class,
ArgMapper.

Runtime for the following test from tst_qstring:

    QString str("%1 %2 %3 %4 %5 %6 %7 %8 %9 foo %10 %11 bar"); // not timed
    str = str.arg("one", "2", "3", "4", "5", "6", "7", "8", "9");
    str = str.arg("ahoy", "there");

went down from 2.2us to 1.5us.

Change-Id: Ic552615fbac646b78ba05eb4e3215e63d202fd94
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2015-01-29 13:41:56 +00:00
bin Use the new warning enabling/disabling macros in qtbase 2014-12-03 18:09:17 +01:00
config.tests Add a configure-time check for an IPC support 2015-01-09 10:58:42 +01:00
dist Merge remote-tracking branch 'origin/5.4.0' into 5.4 2014-12-05 11:53:33 +01:00
doc Merge remote-tracking branch 'origin/5.4' into dev 2015-01-21 11:10:14 +01:00
examples systray example: revert the heart icon to its previous version 2015-01-28 12:51:03 +00:00
lib Initial import from the monolithic Qt. 2011-04-27 12:05:43 +02:00
mkspecs Merge "Merge remote-tracking branch 'origin/5.4' into dev" into refs/staging/dev 2015-01-21 11:14:34 +01:00
qmake turn off nmake inference rule generation on detected conflicts 2015-01-28 12:33:18 +00:00
src QString: optimize multiArg() 2015-01-29 13:41:56 +00:00
tests Remove unused class QPaintBuffer 2015-01-28 15:44:18 +00:00
tools Merge remote-tracking branch 'origin/5.4' into dev 2015-01-21 11:10:14 +01:00
util QUnicodeTables: mark all functions as nothrow 2015-01-10 08:42:55 +01:00
.gitattributes Update the git-archive export options 2012-09-07 15:39:31 +02:00
.gitignore Remove qtdemo from gitignore 2014-09-17 12:38:55 +02:00
.qmake.conf Enable -Werror for all of qtbase 2013-09-04 01:50:10 +02:00
.tag Update the git-archive export options 2012-09-07 15:39:31 +02:00
configure Merge remote-tracking branch 'origin/5.4' into dev 2015-01-21 11:10:14 +01:00
configure.bat Update license headers and add new license files 2014-09-24 12:26:19 +02:00
header.BSD Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
header.FDL Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
header.LGPL Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
header.LGPL3 Android: Don't include Apache code under LGPLv2 license 2014-10-02 05:59:17 +02:00
header.LGPL21 Added header.LGPL21 2014-08-23 07:17:35 +02:00
header.LGPL-ONLY Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
INSTALL Doc: Update links in INSTALL file 2014-01-16 20:37:25 +01:00
LGPL_EXCEPTION.txt Change copyrights from Nokia to Digia 2012-09-22 19:20:11 +02:00
LICENSE.FDL Initial import from the monolithic Qt. 2011-04-27 12:05:43 +02:00
LICENSE.LGPLv3 Update license headers and add new license files 2014-09-24 12:26:19 +02:00
LICENSE.LGPLv21 Update license headers and add new license files 2014-09-24 12:26:19 +02:00
LICENSE.PREVIEW.COMMERCIAL Update LICENSE.PREVIEW.COMMERCIAL license 2013-06-03 20:04:26 +02:00
qtbase.pro remove nonsensical claim about contains() 2014-11-13 14:33:16 +01:00
sync.profile ANGLE: upgrade to 2.1~07d49ef5350a 2014-08-05 16:43:22 +02:00