mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
Userland: Fix unnecessary heap allocation of singleton objects
In order to avoid having multiple instances, we were keeping a pointer
to these singleton objects and only allocating them when it was null.
We have `__cxa_guard_{acquire,release}` in the userland, so there's no
need to do this dance, as the compiler will ensure that the constructors
are only called once.
This commit is contained in:
committed by
Andreas Kling
parent
c1184c1fde
commit
7d11edbe17
@@ -258,10 +258,8 @@ void Object::set_event_filter(Function<bool(Core::Event&)> filter)
|
||||
|
||||
static HashMap<StringView, ObjectClassRegistration*>& object_classes()
|
||||
{
|
||||
static HashMap<StringView, ObjectClassRegistration*>* map;
|
||||
if (!map)
|
||||
map = new HashMap<StringView, ObjectClassRegistration*>;
|
||||
return *map;
|
||||
static HashMap<StringView, ObjectClassRegistration*> s_map;
|
||||
return s_map;
|
||||
}
|
||||
|
||||
ObjectClassRegistration::ObjectClassRegistration(StringView class_name, Function<RefPtr<Object>()> factory, ObjectClassRegistration* parent_class)
|
||||
|
||||
Reference in New Issue
Block a user