mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:07:35 +00:00
LibCore: Store ObjectRegistration names as StringViews
We don't need to be allocating Strings for these names during static initialization. The C-string literals will be stored in the .rodata ELF section, so they're not going anywhere. We can just wrap the .rodata storage for the class names in StringViews and use those in Object registration and lookup APIs.
This commit is contained in:
parent
ea364af965
commit
d6de0613f5
2 changed files with 8 additions and 8 deletions
|
@ -32,7 +32,7 @@ class ObjectClassRegistration {
|
|||
AK_MAKE_NONMOVABLE(ObjectClassRegistration);
|
||||
|
||||
public:
|
||||
ObjectClassRegistration(const String& class_name, Function<NonnullRefPtr<Object>()> factory, ObjectClassRegistration* parent_class = nullptr);
|
||||
ObjectClassRegistration(StringView class_name, Function<NonnullRefPtr<Object>()> factory, ObjectClassRegistration* parent_class = nullptr);
|
||||
~ObjectClassRegistration();
|
||||
|
||||
String class_name() const { return m_class_name; }
|
||||
|
@ -41,10 +41,10 @@ public:
|
|||
bool is_derived_from(const ObjectClassRegistration& base_class) const;
|
||||
|
||||
static void for_each(Function<void(const ObjectClassRegistration&)>);
|
||||
static const ObjectClassRegistration* find(const String& class_name);
|
||||
static const ObjectClassRegistration* find(StringView class_name);
|
||||
|
||||
private:
|
||||
String m_class_name;
|
||||
StringView m_class_name;
|
||||
Function<NonnullRefPtr<Object>()> m_factory;
|
||||
ObjectClassRegistration* m_parent_class { nullptr };
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue