Переглянути джерело

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.
Idan Horowitz 3 роки тому
батько
коміт
cec669a89a
1 змінених файлів з 6 додано та 1 видалено
  1. 6 1
      AK/StringUtils.cpp

+ 6 - 1
AK/StringUtils.cpp

@@ -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)