mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
AK: Exclude StringUtils String APIs from the Kernel
These APIs are only used by userland, and String is OOM-infallible, so let's just ifdef it out of the Kernel.
This commit is contained in:
parent
4c6a1f4db2
commit
cec669a89a
Notes:
sideshowbarker
2024-07-17 18:39:54 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/cec669a89a Pull-request: https://github.com/SerenityOS/serenity/pull/12564 Reviewed-by: https://github.com/MaxWipfli
1 changed files with 6 additions and 1 deletions
|
@ -9,12 +9,15 @@
|
|||
#include <AK/MemMem.h>
|
||||
#include <AK/Memory.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/StringUtils.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
#ifndef KERNEL
|
||||
# include <AK/String.h>
|
||||
#endif
|
||||
|
||||
namespace AK {
|
||||
|
||||
namespace StringUtils {
|
||||
|
@ -415,6 +418,7 @@ Optional<size_t> find_any_of(StringView haystack, StringView needles, SearchDire
|
|||
return {};
|
||||
}
|
||||
|
||||
#ifndef KERNEL
|
||||
String to_snakecase(StringView str)
|
||||
{
|
||||
auto should_insert_underscore = [&](auto i, auto current_char) {
|
||||
|
@ -484,6 +488,7 @@ String replace(StringView str, StringView needle, StringView replacement, bool a
|
|||
replaced_string.append(str.substring_view(last_position, str.length() - last_position));
|
||||
return replaced_string.build();
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: Benchmark against KMP (AK/MemMem.h) and switch over if it's faster for short strings too
|
||||
size_t count(StringView str, StringView needle)
|
||||
|
|
Loading…
Add table
Reference in a new issue