Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Everywhere: Rename DeprecatedFlyString to FlyByteString #25513

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions AK/ByteString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <AK/ByteBuffer.h>
#include <AK/ByteString.h>
#include <AK/DeprecatedFlyString.h>
#include <AK/FlyByteString.h>
#include <AK/Format.h>
#include <AK/Function.h>
#include <AK/StdLibExtras.h>
Expand All @@ -16,7 +16,7 @@

namespace AK {

bool ByteString::operator==(DeprecatedFlyString const& fly_string) const
bool ByteString::operator==(FlyByteString const& fly_string) const
{
return m_impl == fly_string.impl() || view() == fly_string.view();
}
Expand Down Expand Up @@ -337,7 +337,7 @@ ByteString escape_html_entities(StringView html)
return builder.to_byte_string();
}

ByteString::ByteString(DeprecatedFlyString const& string)
ByteString::ByteString(FlyByteString const& string)
: m_impl(string.impl())
{
}
Expand Down
4 changes: 2 additions & 2 deletions AK/ByteString.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class ByteString {
{
}

ByteString(DeprecatedFlyString const&);
ByteString(FlyByteString const&);

static ErrorOr<ByteString> from_utf8(ReadonlyBytes);
static ErrorOr<ByteString> from_utf8(StringView string) { return from_utf8(string.bytes()); }
Expand Down Expand Up @@ -227,7 +227,7 @@ class ByteString {

bool operator==(StringView) const;

bool operator==(DeprecatedFlyString const&) const;
bool operator==(FlyByteString const&) const;

bool operator<(ByteString const&) const;
bool operator>=(ByteString const& other) const { return !(*this < other); }
Expand Down
2 changes: 1 addition & 1 deletion AK/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(AK_SOURCES
ConstrainedStream.cpp
CountingStream.cpp
DOSPackedTime.cpp
DeprecatedFlyString.cpp
FlyByteString.cpp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in alphabetic order.

Error.cpp
FloatingPointStringConversions.cpp
FlyString.cpp
Expand Down
2 changes: 1 addition & 1 deletion AK/Error.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class [[nodiscard]] Error {
}
static Error from_string_view(StringView string_literal) { return Error(string_literal); }

template<OneOf<ByteString, DeprecatedFlyString, String, FlyString> T>
template<OneOf<ByteString, FlyByteString, String, FlyString> T>
static Error from_string_view(T)
{
// `Error::from_string_view(ByteString::formatted(...))` is a somewhat common mistake, which leads to a UAF situation.
Expand Down
28 changes: 14 additions & 14 deletions AK/DeprecatedFlyString.cpp → AK/FlyByteString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

#include <AK/ByteString.h>
#include <AK/DeprecatedFlyString.h>
#include <AK/FlyByteString.h>
#include <AK/HashTable.h>
#include <AK/Optional.h>
#include <AK/Singleton.h>
Expand All @@ -14,27 +14,27 @@

namespace AK {

struct DeprecatedFlyStringImplTraits : public Traits<StringImpl const*> {
struct FlyByteStringImplTraits : public Traits<StringImpl const*> {
static unsigned hash(StringImpl const* s) { return s->hash(); }
static bool equals(StringImpl const* a, StringImpl const* b)
{
return *a == *b;
}
};

static Singleton<HashTable<StringImpl const*, DeprecatedFlyStringImplTraits>> s_table;
static Singleton<HashTable<StringImpl const*, FlyByteStringImplTraits>> s_table;

static HashTable<StringImpl const*, DeprecatedFlyStringImplTraits>& fly_impls()
static HashTable<StringImpl const*, FlyByteStringImplTraits>& fly_impls()
{
return *s_table;
}

void DeprecatedFlyString::did_destroy_impl(Badge<StringImpl>, StringImpl& impl)
void FlyByteString::did_destroy_impl(Badge<StringImpl>, StringImpl& impl)
{
fly_impls().remove(&impl);
}

DeprecatedFlyString::DeprecatedFlyString(ByteString const& string)
FlyByteString::FlyByteString(ByteString const& string)
: m_impl(string.impl())
{
if (string.impl()->is_fly())
Expand All @@ -51,7 +51,7 @@ DeprecatedFlyString::DeprecatedFlyString(ByteString const& string)
}
}

DeprecatedFlyString::DeprecatedFlyString(StringView string)
FlyByteString::FlyByteString(StringView string)
: m_impl(StringImpl::the_empty_stringimpl())
{
if (string.is_null())
Expand All @@ -70,37 +70,37 @@ DeprecatedFlyString::DeprecatedFlyString(StringView string)
}
}

bool DeprecatedFlyString::equals_ignoring_ascii_case(StringView other) const
bool FlyByteString::equals_ignoring_ascii_case(StringView other) const
{
return StringUtils::equals_ignoring_ascii_case(view(), other);
}

bool DeprecatedFlyString::starts_with(StringView str, CaseSensitivity case_sensitivity) const
bool FlyByteString::starts_with(StringView str, CaseSensitivity case_sensitivity) const
{
return StringUtils::starts_with(view(), str, case_sensitivity);
}

bool DeprecatedFlyString::ends_with(StringView str, CaseSensitivity case_sensitivity) const
bool FlyByteString::ends_with(StringView str, CaseSensitivity case_sensitivity) const
{
return StringUtils::ends_with(view(), str, case_sensitivity);
}

DeprecatedFlyString DeprecatedFlyString::to_lowercase() const
FlyByteString FlyByteString::to_lowercase() const
{
return ByteString(*m_impl).to_lowercase();
}

bool DeprecatedFlyString::operator==(ByteString const& other) const
bool FlyByteString::operator==(ByteString const& other) const
{
return m_impl == other.impl() || view() == other.view();
}

bool DeprecatedFlyString::operator==(StringView string) const
bool FlyByteString::operator==(StringView string) const
{
return view() == string;
}

bool DeprecatedFlyString::operator==(char const* string) const
bool FlyByteString::operator==(char const* string) const
{
return view() == string;
}
Expand Down
34 changes: 17 additions & 17 deletions AK/DeprecatedFlyString.h → AK/FlyByteString.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,50 +11,50 @@

namespace AK {

class DeprecatedFlyString {
class FlyByteString {
public:
DeprecatedFlyString()
FlyByteString()
: m_impl(StringImpl::the_empty_stringimpl())
{
}
DeprecatedFlyString(DeprecatedFlyString const& other)
FlyByteString(FlyByteString const& other)
: m_impl(other.impl())
{
}
DeprecatedFlyString(DeprecatedFlyString&& other)
FlyByteString(FlyByteString&& other)
: m_impl(move(other.m_impl))
{
}
DeprecatedFlyString(ByteString const&);
DeprecatedFlyString(StringView);
DeprecatedFlyString(char const* string)
: DeprecatedFlyString(static_cast<ByteString>(string))
FlyByteString(ByteString const&);
FlyByteString(StringView);
FlyByteString(char const* string)
: FlyByteString(static_cast<ByteString>(string))
{
}

static DeprecatedFlyString from_fly_impl(NonnullRefPtr<StringImpl const> impl)
static FlyByteString from_fly_impl(NonnullRefPtr<StringImpl const> impl)
{
VERIFY(impl->is_fly());
DeprecatedFlyString string;
FlyByteString string;
string.m_impl = move(impl);
return string;
}

DeprecatedFlyString& operator=(DeprecatedFlyString const& other)
FlyByteString& operator=(FlyByteString const& other)
{
m_impl = other.m_impl;
return *this;
}

DeprecatedFlyString& operator=(DeprecatedFlyString&& other)
FlyByteString& operator=(FlyByteString&& other)
{
m_impl = move(other.m_impl);
return *this;
}

bool is_empty() const { return !m_impl->length(); }

bool operator==(DeprecatedFlyString const& other) const { return m_impl == other.m_impl; }
bool operator==(FlyByteString const& other) const { return m_impl == other.m_impl; }

bool operator==(ByteString const&) const;

Expand All @@ -69,7 +69,7 @@ class DeprecatedFlyString {
ALWAYS_INLINE u32 hash() const { return m_impl->existing_hash(); }
ALWAYS_INLINE StringView view() const { return m_impl->view(); }

DeprecatedFlyString to_lowercase() const;
FlyByteString to_lowercase() const;

template<Arithmetic T>
Optional<T> to_number(TrimWhitespace trim_whitespace = TrimWhitespace::Yes) const
Expand All @@ -94,12 +94,12 @@ class DeprecatedFlyString {
};

template<>
struct Traits<DeprecatedFlyString> : public DefaultTraits<DeprecatedFlyString> {
static unsigned hash(DeprecatedFlyString const& s) { return s.hash(); }
struct Traits<FlyByteString> : public DefaultTraits<FlyByteString> {
static unsigned hash(FlyByteString const& s) { return s.hash(); }
};

}

#if USING_AK_GLOBALLY
using AK::DeprecatedFlyString;
using AK::FlyByteString;
#endif
8 changes: 4 additions & 4 deletions AK/FlyString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/

#include <AK/DeprecatedFlyString.h>
#include <AK/FlyByteString.h>
#include <AK/FlyString.h>
#include <AK/HashMap.h>
#include <AK/Singleton.h>
Expand Down Expand Up @@ -148,12 +148,12 @@ size_t FlyString::number_of_fly_strings()
return all_fly_strings().size();
}

DeprecatedFlyString FlyString::to_deprecated_fly_string() const
FlyByteString FlyString::to_deprecated_fly_string() const
{
return DeprecatedFlyString(bytes_as_string_view());
return FlyByteString(bytes_as_string_view());
}

ErrorOr<FlyString> FlyString::from_deprecated_fly_string(DeprecatedFlyString const& deprecated_fly_string)
ErrorOr<FlyString> FlyString::from_deprecated_fly_string(FlyByteString const& deprecated_fly_string)
{
return FlyString::from_utf8(deprecated_fly_string.view());
}
Expand Down
6 changes: 3 additions & 3 deletions AK/FlyString.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class FlyString {
static ErrorOr<FlyString> from_utf8(StringView);
static FlyString from_utf8_without_validation(ReadonlyBytes);
template<typename T>
requires(IsOneOf<RemoveCVReference<T>, ByteString, DeprecatedFlyString, FlyString, String>)
requires(IsOneOf<RemoveCVReference<T>, ByteString, FlyByteString, FlyString, String>)
static ErrorOr<String> from_utf8(T&&) = delete;

FlyString(String const&);
Expand Down Expand Up @@ -56,8 +56,8 @@ class FlyString {
[[nodiscard]] static size_t number_of_fly_strings();

// FIXME: Remove these once all code has been ported to FlyString
[[nodiscard]] DeprecatedFlyString to_deprecated_fly_string() const;
static ErrorOr<FlyString> from_deprecated_fly_string(DeprecatedFlyString const&);
[[nodiscard]] FlyByteString to_deprecated_fly_string() const;
Copy link
Contributor

@DanShaders DanShaders Dec 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{to,from}_fly_byte_string, maybe?

static ErrorOr<FlyString> from_deprecated_fly_string(FlyByteString const&);
template<typename T>
requires(IsSame<RemoveCVReference<T>, StringView>)
static ErrorOr<String> from_deprecated_fly_string(T&&) = delete;
Expand Down
2 changes: 1 addition & 1 deletion AK/Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ template<>
struct Formatter<ByteString> : Formatter<StringView> {
};
template<>
struct Formatter<DeprecatedFlyString> : Formatter<StringView> {
struct Formatter<FlyByteString> : Formatter<StringView> {
};

template<typename T>
Expand Down
4 changes: 2 additions & 2 deletions AK/Forward.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ConstrainedStream;
template<typename T>
class Coroutine;
class CountingStream;
class DeprecatedFlyString;
class FlyByteString;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, alphabetic order

class ByteString;
class DeprecatedStringCodePointIterator;
class Duration;
Expand Down Expand Up @@ -174,14 +174,14 @@ using AK::CircularQueue;
using AK::ConstrainedStream;
using AK::Coroutine;
using AK::CountingStream;
using AK::DeprecatedFlyString;
using AK::DeprecatedStringCodePointIterator;
using AK::DoublyLinkedList;
using AK::Duration;
using AK::Error;
using AK::ErrorOr;
using AK::FixedArray;
using AK::FixedPoint;
using AK::FlyByteString;
using AK::FlyString;
using AK::Function;
using AK::GenericLexer;
Expand Down
2 changes: 1 addition & 1 deletion AK/String.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class String : public Detail::StringBase {
[[nodiscard]] static String from_utf8_with_replacement_character(StringView, WithBOMHandling = WithBOMHandling::Yes);

template<typename T>
requires(IsOneOf<RemoveCVReference<T>, ByteString, DeprecatedFlyString, FlyString, String>)
requires(IsOneOf<RemoveCVReference<T>, ByteString, FlyByteString, FlyString, String>)
static ErrorOr<String> from_utf8(T&&) = delete;

[[nodiscard]] static String from_utf8_without_validation(ReadonlyBytes);
Expand Down
4 changes: 2 additions & 2 deletions AK/StringImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

#include <AK/CharacterTypes.h>
#include <AK/DeprecatedFlyString.h>
#include <AK/FlyByteString.h>
#include <AK/StringHash.h>
#include <AK/StringImpl.h>
#include <AK/kmalloc.h>
Expand All @@ -31,7 +31,7 @@ StringImpl::StringImpl(ConstructWithInlineBufferTag, size_t length)
StringImpl::~StringImpl()
{
if (m_fly)
DeprecatedFlyString::did_destroy_impl({}, *this);
FlyByteString::did_destroy_impl({}, *this);
}

NonnullRefPtr<StringImpl const> StringImpl::create_uninitialized(size_t length, char*& buffer)
Expand Down
2 changes: 1 addition & 1 deletion AK/StringImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class StringImpl : public RefCounted<StringImpl> {
unsigned case_insensitive_hash() const;

bool is_fly() const { return m_fly; }
void set_fly(Badge<DeprecatedFlyString>, bool fly) const { m_fly = fly; }
void set_fly(Badge<FlyByteString>, bool fly) const { m_fly = fly; }

private:
enum ConstructTheEmptyStringImplTag {
Expand Down
4 changes: 2 additions & 2 deletions AK/StringView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#ifndef KERNEL
# include <AK/ByteString.h>
# include <AK/DeprecatedFlyString.h>
# include <AK/FlyByteString.h>
# include <AK/FlyString.h>
# include <AK/String.h>
#endif
Expand All @@ -40,7 +40,7 @@ StringView::StringView(ByteString const& string)
{
}

StringView::StringView(DeprecatedFlyString const& string)
StringView::StringView(FlyByteString const& string)
: m_characters(string.characters())
, m_length(string.length())
{
Expand Down
Loading
Loading