summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qringbuffer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools/qringbuffer.cpp')
-rw-r--r--src/corelib/tools/qringbuffer.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/corelib/tools/qringbuffer.cpp b/src/corelib/tools/qringbuffer.cpp
index e38245ca0a..e9b655c01e 100644
--- a/src/corelib/tools/qringbuffer.cpp
+++ b/src/corelib/tools/qringbuffer.cpp
@@ -226,16 +226,15 @@ qint64 QRingBuffer::indexOf(char c, qint64 maxLength, qint64 pos) const
index = 0;
}
- do {
- if (*ptr++ == c)
- return index + pos;
- } while (++index < nextBlockIndex);
+ const char *findPtr = reinterpret_cast<const char *>(memchr(ptr, c,
+ nextBlockIndex - index));
+ if (findPtr)
+ return qint64(findPtr - ptr) + index + pos;
- if (index == maxLength)
+ if (nextBlockIndex == maxLength)
return -1;
- } else {
- index = nextBlockIndex;
}
+ index = nextBlockIndex;
}
return -1;
}