1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-08-02 03:07:35 +00:00

AK+Everywhere: Rename FlyString to DeprecatedFlyString

DeprecatedFlyString relies heavily on DeprecatedString's StringImpl, so
let's rename it to A) match the name of DeprecatedString, B) write a new
FlyString class that is tied to String.
This commit is contained in:
Timothy Flynn 2023-01-08 19:23:00 -05:00 committed by Linus Groh
parent 2eacc7aec1
commit f3db548a3d
316 changed files with 1177 additions and 1177 deletions

View file

@ -2,9 +2,9 @@ set(AK_SOURCES
Assertions.cpp
Base64.cpp
CircularBuffer.cpp
DeprecatedFlyString.cpp
DeprecatedString.cpp
FloatingPointStringConversions.cpp
FlyString.cpp
Format.cpp
FuzzyMatch.cpp
GenericLexer.cpp

View file

@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedFlyString.h>
#include <AK/DeprecatedString.h>
#include <AK/FlyString.h>
#include <AK/HashTable.h>
#include <AK/Optional.h>
#include <AK/Singleton.h>
@ -14,7 +14,7 @@
namespace AK {
struct FlyStringImplTraits : public Traits<StringImpl*> {
struct DeprecatedFlyStringImplTraits : public Traits<StringImpl*> {
static unsigned hash(StringImpl const* s) { return s ? s->hash() : 0; }
static bool equals(StringImpl const* a, StringImpl const* b)
{
@ -24,19 +24,19 @@ struct FlyStringImplTraits : public Traits<StringImpl*> {
}
};
static Singleton<HashTable<StringImpl*, FlyStringImplTraits>> s_table;
static Singleton<HashTable<StringImpl*, DeprecatedFlyStringImplTraits>> s_table;
static HashTable<StringImpl*, FlyStringImplTraits>& fly_impls()
static HashTable<StringImpl*, DeprecatedFlyStringImplTraits>& fly_impls()
{
return *s_table;
}
void FlyString::did_destroy_impl(Badge<StringImpl>, StringImpl& impl)
void DeprecatedFlyString::did_destroy_impl(Badge<StringImpl>, StringImpl& impl)
{
fly_impls().remove(&impl);
}
FlyString::FlyString(DeprecatedString const& string)
DeprecatedFlyString::DeprecatedFlyString(DeprecatedString const& string)
{
if (string.is_null())
return;
@ -55,7 +55,7 @@ FlyString::FlyString(DeprecatedString const& string)
}
}
FlyString::FlyString(StringView string)
DeprecatedFlyString::DeprecatedFlyString(StringView string)
{
if (string.is_null())
return;
@ -74,70 +74,70 @@ FlyString::FlyString(StringView string)
}
template<typename T>
Optional<T> FlyString::to_int(TrimWhitespace trim_whitespace) const
Optional<T> DeprecatedFlyString::to_int(TrimWhitespace trim_whitespace) const
{
return StringUtils::convert_to_int<T>(view(), trim_whitespace);
}
template Optional<i8> FlyString::to_int(TrimWhitespace) const;
template Optional<i16> FlyString::to_int(TrimWhitespace) const;
template Optional<i32> FlyString::to_int(TrimWhitespace) const;
template Optional<i64> FlyString::to_int(TrimWhitespace) const;
template Optional<i8> DeprecatedFlyString::to_int(TrimWhitespace) const;
template Optional<i16> DeprecatedFlyString::to_int(TrimWhitespace) const;
template Optional<i32> DeprecatedFlyString::to_int(TrimWhitespace) const;
template Optional<i64> DeprecatedFlyString::to_int(TrimWhitespace) const;
template<typename T>
Optional<T> FlyString::to_uint(TrimWhitespace trim_whitespace) const
Optional<T> DeprecatedFlyString::to_uint(TrimWhitespace trim_whitespace) const
{
return StringUtils::convert_to_uint<T>(view(), trim_whitespace);
}
template Optional<u8> FlyString::to_uint(TrimWhitespace) const;
template Optional<u16> FlyString::to_uint(TrimWhitespace) const;
template Optional<u32> FlyString::to_uint(TrimWhitespace) const;
template Optional<u64> FlyString::to_uint(TrimWhitespace) const;
template Optional<u8> DeprecatedFlyString::to_uint(TrimWhitespace) const;
template Optional<u16> DeprecatedFlyString::to_uint(TrimWhitespace) const;
template Optional<u32> DeprecatedFlyString::to_uint(TrimWhitespace) const;
template Optional<u64> DeprecatedFlyString::to_uint(TrimWhitespace) const;
#ifndef KERNEL
Optional<double> FlyString::to_double(TrimWhitespace trim_whitespace) const
Optional<double> DeprecatedFlyString::to_double(TrimWhitespace trim_whitespace) const
{
return StringUtils::convert_to_floating_point<double>(view(), trim_whitespace);
}
Optional<float> FlyString::to_float(TrimWhitespace trim_whitespace) const
Optional<float> DeprecatedFlyString::to_float(TrimWhitespace trim_whitespace) const
{
return StringUtils::convert_to_floating_point<float>(view(), trim_whitespace);
}
#endif
bool FlyString::equals_ignoring_case(StringView other) const
bool DeprecatedFlyString::equals_ignoring_case(StringView other) const
{
return StringUtils::equals_ignoring_case(view(), other);
}
bool FlyString::starts_with(StringView str, CaseSensitivity case_sensitivity) const
bool DeprecatedFlyString::starts_with(StringView str, CaseSensitivity case_sensitivity) const
{
return StringUtils::starts_with(view(), str, case_sensitivity);
}
bool FlyString::ends_with(StringView str, CaseSensitivity case_sensitivity) const
bool DeprecatedFlyString::ends_with(StringView str, CaseSensitivity case_sensitivity) const
{
return StringUtils::ends_with(view(), str, case_sensitivity);
}
FlyString FlyString::to_lowercase() const
DeprecatedFlyString DeprecatedFlyString::to_lowercase() const
{
return DeprecatedString(*m_impl).to_lowercase();
}
bool FlyString::operator==(DeprecatedString const& other) const
bool DeprecatedFlyString::operator==(DeprecatedString const& other) const
{
return m_impl == other.impl() || view() == other.view();
}
bool FlyString::operator==(StringView string) const
bool DeprecatedFlyString::operator==(StringView string) const
{
return view() == string;
}
bool FlyString::operator==(char const* string) const
bool DeprecatedFlyString::operator==(char const* string) const
{
return view() == string;
}

View file

@ -11,39 +11,39 @@
namespace AK {
class FlyString {
class DeprecatedFlyString {
public:
FlyString() = default;
FlyString(FlyString const& other)
DeprecatedFlyString() = default;
DeprecatedFlyString(DeprecatedFlyString const& other)
: m_impl(other.impl())
{
}
FlyString(FlyString&& other)
DeprecatedFlyString(DeprecatedFlyString&& other)
: m_impl(move(other.m_impl))
{
}
FlyString(DeprecatedString const&);
FlyString(StringView);
FlyString(char const* string)
: FlyString(static_cast<DeprecatedString>(string))
DeprecatedFlyString(DeprecatedString const&);
DeprecatedFlyString(StringView);
DeprecatedFlyString(char const* string)
: DeprecatedFlyString(static_cast<DeprecatedString>(string))
{
}
static FlyString from_fly_impl(NonnullRefPtr<StringImpl> impl)
static DeprecatedFlyString from_fly_impl(NonnullRefPtr<StringImpl> impl)
{
VERIFY(impl->is_fly());
FlyString string;
DeprecatedFlyString string;
string.m_impl = move(impl);
return string;
}
FlyString& operator=(FlyString const& other)
DeprecatedFlyString& operator=(DeprecatedFlyString const& other)
{
m_impl = other.m_impl;
return *this;
}
FlyString& operator=(FlyString&& other)
DeprecatedFlyString& operator=(DeprecatedFlyString&& other)
{
m_impl = move(other.m_impl);
return *this;
@ -52,7 +52,7 @@ public:
bool is_empty() const { return !m_impl || !m_impl->length(); }
bool is_null() const { return !m_impl; }
bool operator==(FlyString const& other) const { return m_impl == other.m_impl; }
bool operator==(DeprecatedFlyString const& other) const { return m_impl == other.m_impl; }
bool operator==(DeprecatedString const&) const;
@ -67,7 +67,7 @@ public:
ALWAYS_INLINE u32 hash() const { return m_impl ? m_impl->existing_hash() : 0; }
ALWAYS_INLINE StringView view() const { return m_impl ? m_impl->view() : StringView {}; }
FlyString to_lowercase() const;
DeprecatedFlyString to_lowercase() const;
template<typename T = int>
Optional<T> to_int(TrimWhitespace = TrimWhitespace::Yes) const;
@ -95,12 +95,12 @@ private:
};
template<>
struct Traits<FlyString> : public GenericTraits<FlyString> {
static unsigned hash(FlyString const& s) { return s.hash(); }
struct Traits<DeprecatedFlyString> : public GenericTraits<DeprecatedFlyString> {
static unsigned hash(DeprecatedFlyString const& s) { return s.hash(); }
};
}
#if USING_AK_GLOBALLY
using AK::FlyString;
using AK::DeprecatedFlyString;
#endif

View file

@ -5,8 +5,8 @@
*/
#include <AK/ByteBuffer.h>
#include <AK/DeprecatedFlyString.h>
#include <AK/DeprecatedString.h>
#include <AK/FlyString.h>
#include <AK/Format.h>
#include <AK/Function.h>
#include <AK/StdLibExtras.h>
@ -15,7 +15,7 @@
namespace AK {
bool DeprecatedString::operator==(FlyString const& fly_string) const
bool DeprecatedString::operator==(DeprecatedFlyString const& fly_string) const
{
return m_impl == fly_string.impl() || view() == fly_string.view();
}
@ -375,7 +375,7 @@ DeprecatedString escape_html_entities(StringView html)
return builder.to_deprecated_string();
}
DeprecatedString::DeprecatedString(FlyString const& string)
DeprecatedString::DeprecatedString(DeprecatedFlyString const& string)
: m_impl(string.impl())
{
}

View file

@ -93,7 +93,7 @@ public:
{
}
DeprecatedString(FlyString const&);
DeprecatedString(DeprecatedFlyString const&);
[[nodiscard]] static DeprecatedString repeated(char, size_t count);
[[nodiscard]] static DeprecatedString repeated(StringView, size_t count);
@ -212,7 +212,7 @@ public:
bool operator==(StringView) const;
bool operator==(FlyString const&) const;
bool operator==(DeprecatedFlyString const&) const;
bool operator<(DeprecatedString const&) const;
bool operator<(char const*) const;

View file

@ -461,7 +461,7 @@ template<>
struct Formatter<DeprecatedString> : Formatter<StringView> {
};
template<>
struct Formatter<FlyString> : Formatter<StringView> {
struct Formatter<DeprecatedFlyString> : Formatter<StringView> {
};
template<typename T>

View file

@ -27,13 +27,13 @@ class JsonArray;
class JsonObject;
class JsonValue;
class StackInfo;
class DeprecatedFlyString;
class DeprecatedString;
class StringBuilder;
class StringImpl;
class StringView;
class Time;
class URL;
class FlyString;
class String;
class Utf16View;
class Utf32View;
@ -160,6 +160,7 @@ using AK::Bytes;
using AK::CircularBuffer;
using AK::CircularDuplexStream;
using AK::CircularQueue;
using AK::DeprecatedFlyString;
using AK::DeprecatedString;
using AK::DoublyLinkedList;
using AK::DuplexMemoryStream;
@ -167,7 +168,6 @@ using AK::Error;
using AK::ErrorOr;
using AK::FixedArray;
using AK::FixedPoint;
using AK::FlyString;
using AK::Function;
using AK::GenericLexer;
using AK::HashMap;

View file

@ -5,7 +5,7 @@
*/
#include <AK/CharacterTypes.h>
#include <AK/FlyString.h>
#include <AK/DeprecatedFlyString.h>
#include <AK/HashTable.h>
#include <AK/StringHash.h>
#include <AK/StringImpl.h>
@ -32,7 +32,7 @@ StringImpl::StringImpl(ConstructWithInlineBufferTag, size_t length)
StringImpl::~StringImpl()
{
if (m_fly)
FlyString::did_destroy_impl({}, *this);
DeprecatedFlyString::did_destroy_impl({}, *this);
}
NonnullRefPtr<StringImpl> StringImpl::create_uninitialized(size_t length, char*& buffer)

View file

@ -78,7 +78,7 @@ public:
unsigned case_insensitive_hash() const;
bool is_fly() const { return m_fly; }
void set_fly(Badge<FlyString>, bool fly) const { m_fly = fly; }
void set_fly(Badge<DeprecatedFlyString>, bool fly) const { m_fly = fly; }
private:
enum ConstructTheEmptyStringImplTag {

View file

@ -13,8 +13,8 @@
#include <AK/Vector.h>
#ifndef KERNEL
# include <AK/DeprecatedFlyString.h>
# include <AK/DeprecatedString.h>
# include <AK/FlyString.h>
# include <AK/String.h>
#endif
@ -33,7 +33,7 @@ StringView::StringView(DeprecatedString const& string)
{
}
StringView::StringView(FlyString const& string)
StringView::StringView(DeprecatedFlyString const& string)
: m_characters(string.characters())
, m_length(string.length())
{

View file

@ -50,14 +50,14 @@ public:
#ifndef KERNEL
StringView(String const&);
StringView(DeprecatedString const&);
StringView(FlyString const&);
StringView(DeprecatedFlyString const&);
#endif
explicit StringView(ByteBuffer&&) = delete;
#ifndef KERNEL
explicit StringView(String&&) = delete;
explicit StringView(DeprecatedString&&) = delete;
explicit StringView(FlyString&&) = delete;
explicit StringView(DeprecatedFlyString&&) = delete;
#endif
[[nodiscard]] constexpr bool is_null() const