summaryrefslogtreecommitdiff
path: root/AK/MemMem.h
diff options
context:
space:
mode:
authorAndrew Kaster <akaster@serenityos.org>2021-11-20 14:09:22 -0700
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-11-22 05:23:24 +0330
commitbf33a140818efe74917d2044fc70a327723869f5 (patch)
treebee0b7ddd8d613065bf042be9356f5ea95f3d24e /AK/MemMem.h
parent0982a73d1d8c03ed0b7f3686c2a801c543c4c1f7 (diff)
downloadserenity-bf33a140818efe74917d2044fc70a327723869f5.zip
AK: Mark MemMem header-only functions as inline rather than static
Avoid including a per-translation unit copy of all these functions. Also, drive-by two clang-tidy fixes for readability-qualified-auto and readability-implicit-bool-conversion.
Diffstat (limited to 'AK/MemMem.h')
-rw-r--r--AK/MemMem.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/AK/MemMem.h b/AK/MemMem.h
index fb7821c6f6..25a2e455b0 100644
--- a/AK/MemMem.h
+++ b/AK/MemMem.h
@@ -14,8 +14,8 @@
namespace AK {
-namespace {
-const static void* bitap_bitwise(const void* haystack, size_t haystack_length, const void* needle, size_t needle_length)
+namespace Detail {
+inline constexpr const void* bitap_bitwise(const void* haystack, size_t haystack_length, const void* needle, size_t needle_length)
{
VERIFY(needle_length < 32);
@@ -34,7 +34,7 @@ const static void* bitap_bitwise(const void* haystack, size_t haystack_length, c
lookup |= needle_mask[((const u8*)haystack)[i]];
lookup <<= 1;
- if (!(lookup & (0x00000001 << needle_length)))
+ if (0 == (lookup & (0x00000001 << needle_length)))
return ((const u8*)haystack) + i - needle_length + 1;
}
@@ -43,7 +43,7 @@ const static void* bitap_bitwise(const void* haystack, size_t haystack_length, c
}
template<typename HaystackIterT>
-static inline Optional<size_t> memmem(const HaystackIterT& haystack_begin, const HaystackIterT& haystack_end, Span<const u8> needle) requires(requires { (*haystack_begin).data(); (*haystack_begin).size(); })
+inline Optional<size_t> memmem(const HaystackIterT& haystack_begin, const HaystackIterT& haystack_end, Span<const u8> needle) requires(requires { (*haystack_begin).data(); (*haystack_begin).size(); })
{
auto prepare_kmp_partial_table = [&] {
Vector<int, 64> table;
@@ -100,7 +100,7 @@ static inline Optional<size_t> memmem(const HaystackIterT& haystack_begin, const
return {};
}
-static inline Optional<size_t> memmem_optional(const void* haystack, size_t haystack_length, const void* needle, size_t needle_length)
+inline Optional<size_t> memmem_optional(const void* haystack, size_t haystack_length, const void* needle, size_t needle_length)
{
if (needle_length == 0)
return 0;
@@ -115,7 +115,7 @@ static inline Optional<size_t> memmem_optional(const void* haystack, size_t hays
}
if (needle_length < 32) {
- auto ptr = bitap_bitwise(haystack, haystack_length, needle, needle_length);
+ auto const* ptr = Detail::bitap_bitwise(haystack, haystack_length, needle, needle_length);
if (ptr)
return static_cast<size_t>((FlatPtr)ptr - (FlatPtr)haystack);
return {};
@@ -126,7 +126,7 @@ static inline Optional<size_t> memmem_optional(const void* haystack, size_t hays
return memmem(spans.begin(), spans.end(), { (const u8*)needle, needle_length });
}
-static inline const void* memmem(const void* haystack, size_t haystack_length, const void* needle, size_t needle_length)
+inline const void* memmem(const void* haystack, size_t haystack_length, const void* needle, size_t needle_length)
{
auto offset = memmem_optional(haystack, haystack_length, needle, needle_length);
if (offset.has_value())