Skip to content

Truly independent web browser

AK: Remove unused formatting and utility entry points

Shannon Bootha892617f7a0c
diff --git a/AK/FFIHelpers.cpp b/AK/FFIHelpers.cpp
index 5250b73b8ac..e79113efa86 100644
--- a/AK/FFIHelpers.cpp
+++ b/AK/FFIHelpers.cpp
@@ -232,8 +232,3 @@ extern "C" void* ladybird_js_object_storage_alloc(size_t size)
{
return ak_kmalloc(HeapPartition::JSObjectStorage, size);
}
-
-extern "C" void* ladybird_js_object_storage_realloc(void* pointer, size_t new_size)
-{
- return ak_krealloc(HeapPartition::JSObjectStorage, pointer, new_size);
-}
diff --git a/AK/FFIHelpers.h b/AK/FFIHelpers.h
index bef3f5af6fb..ea81fddfa3a 100644
--- a/AK/FFIHelpers.h
+++ b/AK/FFIHelpers.h
@@ -41,8 +41,6 @@ void ladybird_did_end_short_lived_thread();
// Allocations in HeapPartition::JSObjectStorage, where JS objects keep their property values. ak_kfree frees them.
void* ladybird_js_object_storage_alloc(size_t size);
-void* ladybird_js_object_storage_realloc(void*, size_t new_size);
-
FlatPtr ladybird_utf16_string_create_uninitialized(size_t, bool has_latin1_storage);
FlatPtr ladybird_utf16_fly_string_from_utf8(u8 const*, size_t);
FlatPtr ladybird_utf16_fly_string_from_utf16(u16 const*, size_t);
diff --git a/AK/Format.cpp b/AK/Format.cpp
index 19b1dd42c6f..ae4c1661aa9 100644
--- a/AK/Format.cpp
+++ b/AK/Format.cpp
@@ -424,78 +424,6 @@ ErrorOr<void> FormatBuilder::put_i64(
return {};
}
-ErrorOr<void> FormatBuilder::put_fixed_point(
- bool is_negative,
- i64 integer_value,
- u64 fraction_value,
- u64 fraction_one,
- size_t precision,
- u8 base,
- bool upper_case,
- bool zero_pad,
- bool use_separator,
- Align align,
- size_t min_width,
- size_t fraction_max_width,
- char fill,
- SignMode sign_mode)
-{
- StringBuilder string_builder;
- FormatBuilder format_builder { string_builder };
-
- if (is_negative)
- integer_value = -integer_value;
-
- TRY(format_builder.put_u64(static_cast<u64>(integer_value), base, false, upper_case, false, use_separator, Align::Right, 0, ' ', sign_mode, is_negative));
-
- if (fraction_max_width && (zero_pad || fraction_value)) {
- // FIXME: This is a terrible approximation but doing it properly would be a lot of work. If someone is up for that, a good
- // place to start would be the following video from CppCon 2019:
- // https://youtu.be/4P_kbF0EbZM (Stephan T. Lavavej “Floating-Point <charconv>: Making Your Code 10x Faster With C++17's Final Boss”)
-
- if (is_negative && fraction_value)
- fraction_value = fraction_one - fraction_value;
-
- TRY(string_builder.try_append('.'));
-
- if (base == 10) {
- u64 scale = pow<u64>(5, precision);
- // FIXME: overflows (not before: fraction_value = (2^precision - 1) and precision >= 20) (use wider integer type)
- auto fraction = scale * fraction_value;
- TRY(format_builder.put_u64(fraction, base, false, upper_case, true, use_separator, Align::Right, precision));
- } else if (base == 16 || base == 8 || base == 2) {
- auto bits_per_character = log2(base);
- auto fraction = fraction_value << ((bits_per_character - (precision % bits_per_character)) % bits_per_character);
- TRY(format_builder.put_u64(fraction, base, false, upper_case, false, use_separator, Align::Right, precision / bits_per_character + (precision % bits_per_character != 0), '0'));
- } else {
- VERIFY_NOT_REACHED();
- }
- }
-
- auto formatted_string = string_builder.string_view();
- if (fraction_max_width && (zero_pad || fraction_value)) {
- auto point_index = formatted_string.find('.').value_or(0);
- if (!point_index)
- VERIFY_NOT_REACHED();
-
- if (auto formatted_length = (formatted_string.length() - point_index - 1); formatted_length > fraction_max_width) {
- formatted_string = formatted_string.substring_view(0, 1 + point_index + fraction_max_width);
- } else {
- string_builder.append_repeated('0', fraction_max_width - formatted_length);
- formatted_string = string_builder.string_view();
- }
-
- if (!zero_pad)
- formatted_string = formatted_string.trim("0"sv, TrimMode::Right);
-
- if (formatted_string.ends_with('.'))
- formatted_string = formatted_string.trim("."sv, TrimMode::Right);
- }
-
- TRY(put_string(formatted_string, align, min_width, NumericLimits<size_t>::max(), fill));
- return {};
-}
-
template<OneOf<float, double, long double> T>
ErrorOr<void> FormatBuilder::put_floating_point(
T value,
diff --git a/AK/Format.h b/AK/Format.h
index 3a52303f3ee..a9ed0f6356d 100644
--- a/AK/Format.h
+++ b/AK/Format.h
@@ -263,22 +263,6 @@ public:
char fill = ' ',
SignMode sign_mode = SignMode::OnlyIfNeeded);
- ErrorOr<void> put_fixed_point(
- bool is_negative,
- i64 integer_value,
- u64 fraction_value,
- u64 fraction_one,
- size_t precision,
- u8 base = 10,
- bool upper_case = false,
- bool zero_pad = false,
- bool use_separator = false,
- Align align = Align::Right,
- size_t min_width = 0,
- size_t fraction_max_width = 6,
- char fill = ' ',
- SignMode sign_mode = SignMode::OnlyIfNeeded);
-
template<OneOf<float, double, long double> T>
ErrorOr<void> put_floating_point(
T value,
diff --git a/AK/JsonObject.cpp b/AK/JsonObject.cpp
index 207b2946046..c55dbc17e05 100644
--- a/AK/JsonObject.cpp
+++ b/AK/JsonObject.cpp
@@ -199,12 +199,6 @@ bool JsonObject::has_i64(StringView key) const
return value.has_value() && value->is_integer<i64>();
}
-bool JsonObject::has_number(StringView key) const
-{
- auto value = get(key);
- return value.has_value() && value->is_number();
-}
-
bool JsonObject::has_array(StringView key) const
{
auto value = get(key);
diff --git a/AK/JsonObject.h b/AK/JsonObject.h
index dbd6a27ea4f..6bdb8c55603 100644
--- a/AK/JsonObject.h
+++ b/AK/JsonObject.h
@@ -44,7 +44,6 @@ public:
[[nodiscard]] bool has_i32(StringView key) const;
[[nodiscard]] bool has_u32(StringView key) const;
[[nodiscard]] bool has_i64(StringView key) const;
- [[nodiscard]] bool has_number(StringView key) const;
[[nodiscard]] bool has_array(StringView key) const;
[[nodiscard]] bool has_object(StringView key) const;
diff --git a/AK/OptionParser.cpp b/AK/OptionParser.cpp
index 5dc39b8fc48..1b76d4653c6 100644
--- a/AK/OptionParser.cpp
+++ b/AK/OptionParser.cpp
@@ -9,14 +9,6 @@
namespace AK {
-void OptionParser::reset_state()
-{
- m_arg_index = 0;
- m_consumed_args = 0;
- m_index_into_multioption_argument = 0;
- m_stop_on_first_non_option = false;
-}
-
OptionParser::GetOptResult OptionParser::getopt(Span<StringView> args, StringView short_options, Span<Option const> long_options, Optional<int&> out_long_option_index)
{
m_args = args;
diff --git a/AK/OptionParser.h b/AK/OptionParser.h
index f44079778ab..53d53925eb5 100644
--- a/AK/OptionParser.h
+++ b/AK/OptionParser.h
@@ -35,7 +35,6 @@ public:
};
GetOptResult getopt(Span<StringView> args, StringView short_options, Span<Option const> long_options, Optional<int&> out_long_option_index);
- void reset_state();
private:
Optional<ArgumentRequirement> lookup_short_option_requirement(char option) const;
diff --git a/AK/StringBuilder.cpp b/AK/StringBuilder.cpp
index abbb0782bdf..d1fc160c482 100644
--- a/AK/StringBuilder.cpp
+++ b/AK/StringBuilder.cpp
@@ -8,7 +8,6 @@
#include <AK/ByteBuffer.h>
#include <AK/ByteString.h>
#include <AK/Checked.h>
-#include <AK/FlyString.h>
#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/StringData.h>
@@ -455,11 +454,6 @@ String StringBuilder::to_string_without_validation()
return String::from_string_builder_without_validation({}, *this);
}
-ErrorOr<FlyString> StringBuilder::to_fly_string() const
-{
- return FlyString::from_utf8(string_view());
-}
-
u8* StringBuilder::data()
{
return m_buffer.data() + string_builder_prefix_size();
diff --git a/AK/StringBuilder.h b/AK/StringBuilder.h
index 5223e533f76..5bcaf18e456 100644
--- a/AK/StringBuilder.h
+++ b/AK/StringBuilder.h
@@ -127,8 +127,6 @@ public:
[[nodiscard]] String to_string_without_validation();
ErrorOr<String> to_string();
- ErrorOr<FlyString> to_fly_string() const;
-
[[nodiscard]] ErrorOr<ByteBuffer> to_byte_buffer() const;
[[nodiscard]] StringView string_view() const;