mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 11:36:10 +00:00
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.
This commit is contained in:
parent
0982a73d1d
commit
bf33a14081
Notes:
sideshowbarker
2024-07-18 00:53:13 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/bf33a140818 Pull-request: https://github.com/SerenityOS/serenity/pull/10985 Reviewed-by: https://github.com/alimpfard
1 changed files with 7 additions and 7 deletions
14
AK/MemMem.h
14
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())
|
||||
|
|
Loading…
Add table
Reference in a new issue