mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:58:11 +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
1 changed files with 6 additions and 1 deletions
|
@ -9,12 +9,15 @@
|
||||||
#include <AK/MemMem.h>
|
#include <AK/MemMem.h>
|
||||||
#include <AK/Memory.h>
|
#include <AK/Memory.h>
|
||||||
#include <AK/Optional.h>
|
#include <AK/Optional.h>
|
||||||
#include <AK/String.h>
|
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
#include <AK/StringUtils.h>
|
#include <AK/StringUtils.h>
|
||||||
#include <AK/StringView.h>
|
#include <AK/StringView.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
|
|
||||||
|
#ifndef KERNEL
|
||||||
|
# include <AK/String.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
||||||
namespace StringUtils {
|
namespace StringUtils {
|
||||||
|
@ -415,6 +418,7 @@ Optional<size_t> find_any_of(StringView haystack, StringView needles, SearchDire
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef KERNEL
|
||||||
String to_snakecase(StringView str)
|
String to_snakecase(StringView str)
|
||||||
{
|
{
|
||||||
auto should_insert_underscore = [&](auto i, auto current_char) {
|
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));
|
replaced_string.append(str.substring_view(last_position, str.length() - last_position));
|
||||||
return replaced_string.build();
|
return replaced_string.build();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// TODO: Benchmark against KMP (AK/MemMem.h) and switch over if it's faster for short strings too
|
// 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)
|
size_t count(StringView str, StringView needle)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue