mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 10:28:13 +00:00
AK: Allow inlining more string functions
This commit is contained in:
parent
ed0068d04d
commit
a4f320c76b
4 changed files with 17 additions and 24 deletions
16
AK/String.h
16
AK/String.h
|
@ -42,7 +42,11 @@ public:
|
|||
~String() = default;
|
||||
|
||||
String() = default;
|
||||
String(const StringView&);
|
||||
|
||||
String(const StringView& view)
|
||||
{
|
||||
m_impl = StringImpl::create(view.characters_without_null_termination(), view.length());
|
||||
}
|
||||
|
||||
String(const String& other)
|
||||
: m_impl(const_cast<String&>(other).m_impl)
|
||||
|
@ -203,7 +207,10 @@ public:
|
|||
|
||||
[[nodiscard]] String isolated_copy() const;
|
||||
|
||||
[[nodiscard]] static String empty();
|
||||
[[nodiscard]] static String empty()
|
||||
{
|
||||
return StringImpl::the_empty_stringimpl();
|
||||
}
|
||||
|
||||
[[nodiscard]] StringImpl* impl() { return m_impl.ptr(); }
|
||||
[[nodiscard]] const StringImpl* impl() const { return m_impl.ptr(); }
|
||||
|
@ -265,7 +272,10 @@ public:
|
|||
return formatted("{}", value);
|
||||
}
|
||||
|
||||
[[nodiscard]] StringView view() const;
|
||||
[[nodiscard]] StringView view() const
|
||||
{
|
||||
return { characters(), length() };
|
||||
}
|
||||
|
||||
int replace(const String& needle, const String& replacement, bool all_occurrences = false);
|
||||
size_t count(const String& needle) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue