diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2021-08-12 08:56:46 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2021-08-21 01:28:27 +0200 |
commit | bd52059eef7c96031972b5bee03067f3cb0f038d (patch) | |
tree | 6947d7986e4ce3b16b4222e1ea26385e3cdce918 /src/3rdparty/harfbuzz-ng/src/hb-coretext.cc | |
parent | 62572f0a18af401f778875569eac9203f0d69f89 (diff) |
QMetaEnum: avoid quadratic behavior in valueToKeys()
QByteArray (thankfully) doesn't have the prepend "optimization", so
prepend() is a linear operation, calling it in a loop thus makes the
algorithm quadratic.
To fix, simply remember the parts in a QVLA (an upper bound on the
size of which is easily calculated) and then build the result by
reverse-iterating over the QVLA.
This join_reversed() function is possibly useful elsewhere, but I left
it locally in the unnamed namespace to ease cherry-picking.
The new stringDataView() function is more universally useful, too, and
will be used in a subsequent other change. It return QL1S instead of
QByteArrayView because the latter is scheduled to become a non-string
type, and already lacks certain features (e.g. qTokenize() doesn't
work on QBA, due to lack of a Qt::CaseSensitivity argument in
QBA::indexOf()). It's also a Qt 6 addition, so not available in
5.15. We can revisit this decision later, when QBAV (or, possibly,
QU8SV) has caught up.
Amends 05e0dfa0060aab80afc696161226b2ab0cddfbf9.
Results indicate a ~2x speedup:
PASS : tst_QMetaEnum::valueToKeys(1 bits set)
- 0.00026 msecs per iteration (total: 70, iterations: 262144)
+ 0.00017 msecs per iteration (total: 90, iterations: 524288)
PASS : tst_QMetaEnum::valueToKeys(2 bits set)
- 0.00037 msecs per iteration (total: 98, iterations: 262144)
+ 0.00019 msecs per iteration (total: 52, iterations: 262144)
PASS : tst_QMetaEnum::valueToKeys(3 bits set)
- 0.00040 msecs per iteration (total: 53, iterations: 131072)
+ 0.00021 msecs per iteration (total: 56, iterations: 262144)
PASS : tst_QMetaEnum::valueToKeys(4 bits set)
- 0.00047 msecs per iteration (total: 62, iterations: 131072)
+ 0.00022 msecs per iteration (total: 60, iterations: 262144)
PASS : tst_QMetaEnum::valueToKeys(5 bits set)
- 0.00048 msecs per iteration (total: 63, iterations: 131072)
+ 0.00024 msecs per iteration (total: 64, iterations: 262144)
PASS : tst_QMetaEnum::valueToKeys(6 bits set)
- 0.00061 msecs per iteration (total: 80, iterations: 131072)
+ 0.00027 msecs per iteration (total: 71, iterations: 262144)
PASS : tst_QMetaEnum::valueToKeys(7 bits set)
- 0.00063 msecs per iteration (total: 83, iterations: 131072)
+ 0.00027 msecs per iteration (total: 73, iterations: 262144)
PASS : tst_QMetaEnum::valueToKeys(8 bits set)
- 0.00069 msecs per iteration (total: 91, iterations: 131072)
+ 0.00030 msecs per iteration (total: 81, iterations: 262144)
PASS : tst_QMetaEnum::valueToKeys(9 bits set)
- 0.00070 msecs per iteration (total: 92, iterations: 131072)
+ 0.00031 msecs per iteration (total: 83, iterations: 262144)
PASS : tst_QMetaEnum::valueToKeys(10 bits set)
- 0.00074 msecs per iteration (total: 98, iterations: 131072)
+ 0.00034 msecs per iteration (total: 91, iterations: 262144)
PASS : tst_QMetaEnum::valueToKeys(11 bits set)
- 0.000762 msecs per iteration (total: 100, iterations: 131072)
+ 0.00035 msecs per iteration (total: 92, iterations: 262144)
PASS : tst_QMetaEnum::valueToKeys(12 bits set)
- 0.00088 msecs per iteration (total: 58, iterations: 65536)
+ 0.000381 msecs per iteration (total: 100, iterations: 262144)
PASS : tst_QMetaEnum::valueToKeys(13 bits set)
- 0.00094 msecs per iteration (total: 62, iterations: 65536)
+ 0.00038 msecs per iteration (total: 51, iterations: 131072)
PASS : tst_QMetaEnum::valueToKeys(14 bits set)
- 0.00099 msecs per iteration (total: 65, iterations: 65536)
+ 0.00041 msecs per iteration (total: 55, iterations: 131072)
PASS : tst_QMetaEnum::valueToKeys(15 bits set)
- 0.0010 msecs per iteration (total: 67, iterations: 65536)
+ 0.00042 msecs per iteration (total: 56, iterations: 131072)
PASS : tst_QMetaEnum::valueToKeys(16 bits set)
- 0.0010 msecs per iteration (total: 70, iterations: 65536)
+ 0.00044 msecs per iteration (total: 58, iterations: 131072)
PASS : tst_QMetaEnum::valueToKeys(17 bits set)
- 0.0011 msecs per iteration (total: 73, iterations: 65536)
+ 0.00046 msecs per iteration (total: 61, iterations: 131072)
PASS : tst_QMetaEnum::valueToKeys(18 bits set)
- 0.0012 msecs per iteration (total: 79, iterations: 65536)
+ 0.00048 msecs per iteration (total: 63, iterations: 131072)
PASS : tst_QMetaEnum::valueToKeys(19 bits set)
- 0.0012 msecs per iteration (total: 79, iterations: 65536)
+ 0.00051 msecs per iteration (total: 67, iterations: 131072)
PASS : tst_QMetaEnum::valueToKeys(20 bits set)
- 0.0012 msecs per iteration (total: 80, iterations: 65536)
+ 0.00054 msecs per iteration (total: 71, iterations: 131072)
PASS : tst_QMetaEnum::valueToKeys(21 bits set)
- 0.0012 msecs per iteration (total: 83, iterations: 65536)
+ 0.00090 msecs per iteration (total: 59, iterations: 65536)
PASS : tst_QMetaEnum::valueToKeys(22 bits set)
- 0.0012 msecs per iteration (total: 85, iterations: 65536)
+ 0.00057 msecs per iteration (total: 76, iterations: 131072)
PASS : tst_QMetaEnum::valueToKeys(23 bits set)
- 0.0013 msecs per iteration (total: 87, iterations: 65536)
+ 0.00059 msecs per iteration (total: 78, iterations: 131072)
PASS : tst_QMetaEnum::valueToKeys(24 bits set)
- 0.0014 msecs per iteration (total: 93, iterations: 65536)
+ 0.00065 msecs per iteration (total: 86, iterations: 131072)
PASS : tst_QMetaEnum::valueToKeys(25 bits set)
- 0.0014 msecs per iteration (total: 94, iterations: 65536)
+ 0.00063 msecs per iteration (total: 83, iterations: 131072)
PASS : tst_QMetaEnum::valueToKeys(26 bits set)
- 0.00028 msecs per iteration (total: 74, iterations: 262144)
+ 0.00017 msecs per iteration (total: 94, iterations: 524288)
PASS : tst_QMetaEnum::valueToKeys(27 bits set)
- 0.0014 msecs per iteration (total: 98, iterations: 65536)
+ 0.00063 msecs per iteration (total: 83, iterations: 131072)
PASS : tst_QMetaEnum::valueToKeys(28 bits set)
- 0.0014 msecs per iteration (total: 96, iterations: 65536)
+ 0.00065 msecs per iteration (total: 86, iterations: 131072)
PASS : tst_QMetaEnum::valueToKeys(29 bits set)
- 0.0014 msecs per iteration (total: 98, iterations: 65536)
+ 0.00064 msecs per iteration (total: 84, iterations: 131072)
PASS : tst_QMetaEnum::valueToKeys(30 bits set)
- 0.0014 msecs per iteration (total: 97, iterations: 65536)
+ 0.00064 msecs per iteration (total: 84, iterations: 131072)
Pick-to: 6.2 5.15
Change-Id: Ie456b71b39c118001987716e30642f08f5e8dcdb
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/3rdparty/harfbuzz-ng/src/hb-coretext.cc')
0 files changed, 0 insertions, 0 deletions