13 memset(skiptable, l, 256*
sizeof(
uchar));
26 const uchar *current = cc +
index + pl_minus_one;
28 while (current <
end) {
33 if (*(current - skip) != puc[pl_minus_one - skip])
37 if (skip > pl_minus_one)
38 return (current - cc) - skip + 1;
42 if (skiptable[*(current - skip)] == pl)
47 if (current >
end - skip)
87 memset(
p.q_skiptable, 0,
sizeof(
p.q_skiptable));
153 q_pattern =
other.q_pattern;
154 memcpy(&
p, &
other.p,
sizeof(
p));
184 p.p,
p.l,
p.q_skiptable);
203 p.p,
p.l,
p.q_skiptable);
239 uchar skiptable[256];
241 if (haystackOffset < 0)
243 return bm_find((
const uchar *)haystack, haystackLen, haystackOffset,
244 (
const uchar *)needle, needleLen, skiptable);
248 if (sl_minus_1 < sizeof(std::size_t) * CHAR_BIT) \
249 hashHaystack -= std::size_t(a) << sl_minus_1; \
259 const auto l = haystackLen;
260 const auto sl = needleLen;
263 if (std::size_t(sl + from) > std::size_t(l))
271 return findChar(haystack0, haystackLen, needle[0], from);
278 if (l > 500 && sl > 5)
287 const char *haystack = haystack0 + from;
288 const char *
end = haystack0 + (l - sl);
289 const auto sl_minus_1 = std::size_t(sl - 1);
290 std::size_t hashNeedle = 0, hashHaystack = 0;
292 for (idx = 0; idx < sl; ++idx) {
293 hashNeedle = ((hashNeedle<<1) + needle[idx]);
294 hashHaystack = ((hashHaystack<<1) + haystack[idx]);
296 hashHaystack -= *(haystack + sl_minus_1);
298 while (haystack <=
end) {
299 hashHaystack += *(haystack + sl_minus_1);
300 if (hashHaystack == hashNeedle && *needle == *haystack
301 && memcmp(needle, haystack, sl) == 0)
302 return haystack - haystack0;
389 return bm_find(
reinterpret_cast<const uchar *
>(haystack), hlen, from,
390 reinterpret_cast<const uchar *
>(needle), nlen, m_skiptable.data);
QByteArrayMatcher & operator=(const QByteArrayMatcher &other)
Assigns the other byte array matcher to this byte array matcher.
Q_WEAK_OVERLOAD qsizetype indexIn(const QByteArray &ba, qsizetype from=0) const
QByteArrayMatcher()
Constructs an empty byte array matcher that won't match anything.
~QByteArrayMatcher()
Destroys the byte array matcher.
QByteArray pattern() const
Returns the byte array pattern that this byte array matcher will search for.
void setPattern(const QByteArray &pattern)
Sets the byte array that this byte array matcher will search for to pattern.
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
Q_CORE_EXPORT qsizetype indexOfIn(const char *needle, size_t nlen, const char *haystack, qsizetype hlen, qsizetype from) const noexcept
Combined button and popup list for selecting options.
size_t qstrlen(const char *str)
static qsizetype findChar(const char *str, qsizetype len, char ch, qsizetype from)
static qsizetype qFindByteArrayBoyerMoore(const char *haystack, qsizetype haystackLen, qsizetype haystackOffset, const char *needle, qsizetype needleLen)
static QT_BEGIN_NAMESPACE void bm_init_skiptable(const uchar *cc, qsizetype len, uchar *skiptable)
static qsizetype bm_find(const uchar *cc, qsizetype l, qsizetype index, const uchar *puc, qsizetype pl, const uchar *skiptable)
qsizetype qFindByteArray(const char *haystack0, qsizetype haystackLen, qsizetype from, const char *needle, qsizetype needleLen)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLenum GLuint GLenum GLsizei length
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data