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:
Daniel Bertalan 2022-01-28 21:22:13 +01:00 committed by Andreas Kling
commit 7d11edbe17
Notes: sideshowbarker 2024-07-17 20:04:47 +09:00
9 changed files with 18 additions and 35 deletions

View file

@ -10,10 +10,8 @@ namespace Clipboard {
Storage& Storage::the()
{
static Storage* s_the;
if (!s_the)
s_the = new Storage;
return *s_the;
static Storage s_the;
return s_the;
}
Storage::Storage()