mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
AK: Make FlyString-to-FlyString comparison inline & trivial
This should never boil down to more than a machine word comparison.
This commit is contained in:
@@ -89,11 +89,6 @@ StringView FlyString::bytes_as_string_view() const
|
|||||||
return m_data.bytes();
|
return m_data.bytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FlyString::operator==(FlyString const& other) const
|
|
||||||
{
|
|
||||||
return m_data == other.m_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FlyString::operator==(String const& other) const
|
bool FlyString::operator==(String const& other) const
|
||||||
{
|
{
|
||||||
return m_data == other;
|
return m_data == other;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public:
|
|||||||
[[nodiscard]] ReadonlyBytes bytes() const;
|
[[nodiscard]] ReadonlyBytes bytes() const;
|
||||||
[[nodiscard]] StringView bytes_as_string_view() const;
|
[[nodiscard]] StringView bytes_as_string_view() const;
|
||||||
|
|
||||||
[[nodiscard]] bool operator==(FlyString const& other) const;
|
[[nodiscard]] ALWAYS_INLINE bool operator==(FlyString const& other) const { return m_data.raw({}) == other.m_data.raw({}); }
|
||||||
[[nodiscard]] bool operator==(String const&) const;
|
[[nodiscard]] bool operator==(String const&) const;
|
||||||
[[nodiscard]] bool operator==(StringView) const;
|
[[nodiscard]] bool operator==(StringView) const;
|
||||||
[[nodiscard]] bool operator==(char const*) const;
|
[[nodiscard]] bool operator==(char const*) const;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/Badge.h>
|
||||||
#include <AK/Endian.h>
|
#include <AK/Endian.h>
|
||||||
#include <AK/Forward.h>
|
#include <AK/Forward.h>
|
||||||
|
|
||||||
@@ -70,6 +71,8 @@ public:
|
|||||||
|
|
||||||
void did_create_fly_string(Badge<FlyString>) const;
|
void did_create_fly_string(Badge<FlyString>) const;
|
||||||
|
|
||||||
|
[[nodiscard]] ALWAYS_INLINE FlatPtr raw(Badge<FlyString>) const { return bit_cast<FlatPtr>(m_data); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
template<typename Func>
|
template<typename Func>
|
||||||
ErrorOr<void> replace_with_new_string(size_t byte_count, Func&& callback)
|
ErrorOr<void> replace_with_new_string(size_t byte_count, Func&& callback)
|
||||||
|
|||||||
Reference in New Issue
Block a user