mirror of https://github.com/qt/qtbase.git
In the case of QString, the vast majority of searches are case- sensitive, so by inlining we make the user code call qustrchr() directly instead of QtPrivate::findString(). In the case of QByteArray, the call is to memchr(), which being a compiler intrinsic, may itself be inlined or even just resolved at compile time. In both cases, a great deal of searches use from=0. Benchmark for QByteArray; before: 8.83207052 nsecs per iteration 22.01568546 CPU cycles per iteration, 2.49 GHz 60.00000331 instructions per iteration, 2.725 instr/cycle 21.00000281 branch instructions per iteration, 2.38 G/sec After: 6.42561493 nsecs per iteration 16.01623130 CPU cycles per iteration, 2.49 GHz 49.00000261 instructions per iteration, 3.059 instr/cycle 18.00000211 branch instructions per iteration, 2.8 G/sec This shaves 6 cycles in the execution and 11 instructions (3 of which were branches), slightly improving the IPC raito, for the QByteArray case. For QByteArrayView, there are 2 fewer instructions (1 a branch), but the number of cycles is the same at 16. Task-number: QTBUG-119750 Change-Id: Ica7a43f6147b49c187ccfffd179e2204ebb6a348 Reviewed-by: Marc Mutz <marc.mutz@qt.io> |
||
---|---|---|
.github/workflows | ||
LICENSES | ||
bin | ||
cmake | ||
coin | ||
config.tests | ||
dist | ||
doc | ||
examples | ||
lib | ||
libexec | ||
mkspecs | ||
qmake | ||
src | ||
tests | ||
util | ||
.cmake.conf | ||
.gitattributes | ||
.gitignore | ||
.lgtm.yml | ||
.tag | ||
CMakeLists.txt | ||
config_help.txt | ||
configure | ||
configure.bat | ||
configure.cmake | ||
dependencies.yaml | ||
qt_cmdline.cmake |