summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qxpmhandler.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-02-25 03:54:13 +0100
committerMarc Mutz <marc.mutz@kdab.com>2017-04-24 18:51:52 +0000
commitbfcc2902a4f4f3d062962e3ba7bf19158d1f56d5 (patch)
tree2f05d2731a5672a67ef987bc4c31860331969c08 /src/gui/image/qxpmhandler.cpp
parent93570810d8813691e4f8b7ade34b0f085c6f0b8d (diff)
QtBase: use new QStaticByteArrayMatcher where applicable
Even for compilers that don't yet support C++14 constexpr, this should improve performance of searches a lot, if, indeed, Boyer-Moore still is an optimization over linear searching at all in these days of hardware prefetchers and deep CPU pipelines, because the setup cost is only incurred once. As function-statics, we also don't care about startup ordering and cost. It's a pity that the platform that would benefit the most - Windows - doesn't have constexpr support, yet. Change-Id: I827df135854fd6fbd6546e248dc37ef0fbaf1792 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Diffstat (limited to 'src/gui/image/qxpmhandler.cpp')
-rw-r--r--src/gui/image/qxpmhandler.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp
index ce7f7b8a0f..9c54b9ada4 100644
--- a/src/gui/image/qxpmhandler.cpp
+++ b/src/gui/image/qxpmhandler.cpp
@@ -42,6 +42,7 @@
#ifndef QT_NO_IMAGEFORMAT_XPM
#include <private/qcolor_p.h>
+#include <qbytearraymatcher.h>
#include <qimage.h>
#include <qmap.h>
#include <qtextstream.h>
@@ -1041,7 +1042,9 @@ bool qt_read_xpm_image_or_array(QIODevice *device, const char * const * source,
if ((readBytes = device->readLine(buf.data(), buf.size())) < 0)
return false;
- if (buf.indexOf("/* XPM") != 0) {
+ static Q_RELAXED_CONSTEXPR auto matcher = qMakeStaticByteArrayMatcher("/* XPM");
+
+ if (matcher.indexIn(buf) != 0) {
while (readBytes > 0) {
device->ungetChar(buf.at(readBytes - 1));
--readBytes;