mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-18 15:32:22 +00:00
AK: Inline most StringBase member functions
More work on recovering the performance regression from DeprecatedFlyString removal. Local measurements on my MBP: - 2.5% speedup on Octane/zlib.js - 2% speedup on Octane/typescript.js
This commit is contained in:
parent
a0f3099333
commit
53cac71cec
Notes:
github-actions[bot]
2025-03-26 12:05:12 +00:00
Author: https://github.com/awesomekling
Commit: 53cac71cec
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4093
5 changed files with 109 additions and 104 deletions
|
@ -7,15 +7,18 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Error.h>
|
||||
#include <AK/FlyString.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/StringBase.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/kmalloc.h>
|
||||
|
||||
namespace AK::Detail {
|
||||
|
||||
static constexpr size_t MAX_SHORT_STRING_BYTE_COUNT = sizeof(StringData*) - sizeof(u8);
|
||||
|
||||
class StringData;
|
||||
|
||||
void did_destroy_fly_string_data(Badge<StringData>, StringData const&);
|
||||
|
||||
class StringData final : public RefCounted<StringData> {
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<StringData>> create_uninitialized(size_t byte_count, u8*& buffer)
|
||||
|
@ -63,7 +66,7 @@ public:
|
|||
|
||||
void operator delete(void* ptr)
|
||||
{
|
||||
kfree_sized(ptr, static_cast<StringData const*>(ptr)->m_capacity);
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
~StringData()
|
||||
|
@ -71,7 +74,7 @@ public:
|
|||
if (m_substring)
|
||||
substring_data().superstring->unref();
|
||||
if (m_is_fly_string)
|
||||
FlyString::did_destroy_fly_string_data({}, *this);
|
||||
Detail::did_destroy_fly_string_data({}, *this);
|
||||
}
|
||||
|
||||
SubstringData const& substring_data() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue