diff options
-rw-r--r-- | Userland/Libraries/LibCore/Object.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Clipboard.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Desktop.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/DisplayLink.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Menu.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/FontDatabase.cpp | 7 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Loader/ContentFilter.cpp | 4 | ||||
-rw-r--r-- | Userland/Services/Clipboard/Storage.cpp | 6 | ||||
-rw-r--r-- | Userland/Services/Taskbar/WindowList.cpp | 6 |
9 files changed, 18 insertions, 35 deletions
diff --git a/Userland/Libraries/LibCore/Object.cpp b/Userland/Libraries/LibCore/Object.cpp index 19dd4134b4..66c47b0bf5 100644 --- a/Userland/Libraries/LibCore/Object.cpp +++ b/Userland/Libraries/LibCore/Object.cpp @@ -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) diff --git a/Userland/Libraries/LibGUI/Clipboard.cpp b/Userland/Libraries/LibGUI/Clipboard.cpp index 156b8a72ec..7038c9cfaa 100644 --- a/Userland/Libraries/LibGUI/Clipboard.cpp +++ b/Userland/Libraries/LibGUI/Clipboard.cpp @@ -44,10 +44,8 @@ void Clipboard::initialize(Badge<Application>) Clipboard& Clipboard::the() { - static Clipboard* s_the; - if (!s_the) - s_the = new Clipboard; - return *s_the; + static Clipboard s_the; + return s_the; } Clipboard::DataAndType Clipboard::fetch_data_and_type() const diff --git a/Userland/Libraries/LibGUI/Desktop.cpp b/Userland/Libraries/LibGUI/Desktop.cpp index f9b23a320f..9c5f500db5 100644 --- a/Userland/Libraries/LibGUI/Desktop.cpp +++ b/Userland/Libraries/LibGUI/Desktop.cpp @@ -16,10 +16,8 @@ namespace GUI { Desktop& Desktop::the() { - static Desktop* the; - if (!the) - the = new Desktop; - return *the; + static Desktop s_the; + return s_the; } Desktop::Desktop() diff --git a/Userland/Libraries/LibGUI/DisplayLink.cpp b/Userland/Libraries/LibGUI/DisplayLink.cpp index 3aad5a03a9..1cc4720bb4 100644 --- a/Userland/Libraries/LibGUI/DisplayLink.cpp +++ b/Userland/Libraries/LibGUI/DisplayLink.cpp @@ -31,10 +31,8 @@ private: static HashMap<i32, RefPtr<DisplayLinkCallback>>& callbacks() { - static HashMap<i32, RefPtr<DisplayLinkCallback>>* map; - if (!map) - map = new HashMap<i32, RefPtr<DisplayLinkCallback>>; - return *map; + static HashMap<i32, RefPtr<DisplayLinkCallback>> s_map; + return s_map; } static i32 s_next_callback_id = 1; diff --git a/Userland/Libraries/LibGUI/Menu.cpp b/Userland/Libraries/LibGUI/Menu.cpp index 9764e64855..7eaca2aacd 100644 --- a/Userland/Libraries/LibGUI/Menu.cpp +++ b/Userland/Libraries/LibGUI/Menu.cpp @@ -20,10 +20,8 @@ static IDAllocator s_menu_id_allocator; static HashMap<int, Menu*>& all_menus() { - static HashMap<int, Menu*>* map; - if (!map) - map = new HashMap<int, Menu*>(); - return *map; + static HashMap<int, Menu*> s_map; + return s_map; } Menu* Menu::from_menu_id(int menu_id) diff --git a/Userland/Libraries/LibGfx/FontDatabase.cpp b/Userland/Libraries/LibGfx/FontDatabase.cpp index e2e5397541..fee528d24e 100644 --- a/Userland/Libraries/LibGfx/FontDatabase.cpp +++ b/Userland/Libraries/LibGfx/FontDatabase.cpp @@ -15,13 +15,10 @@ namespace Gfx { -static FontDatabase* s_the; - FontDatabase& FontDatabase::the() { - if (!s_the) - s_the = new FontDatabase; - return *s_the; + static FontDatabase s_the; + return s_the; } static RefPtr<Font> s_default_font; diff --git a/Userland/Libraries/LibWeb/Loader/ContentFilter.cpp b/Userland/Libraries/LibWeb/Loader/ContentFilter.cpp index 5d1e1777fe..b725d859de 100644 --- a/Userland/Libraries/LibWeb/Loader/ContentFilter.cpp +++ b/Userland/Libraries/LibWeb/Loader/ContentFilter.cpp @@ -11,8 +11,8 @@ namespace Web { ContentFilter& ContentFilter::the() { - static ContentFilter* filter = new ContentFilter; - return *filter; + static ContentFilter filter; + return filter; } ContentFilter::ContentFilter() diff --git a/Userland/Services/Clipboard/Storage.cpp b/Userland/Services/Clipboard/Storage.cpp index f89f300af3..5bc7f48aaa 100644 --- a/Userland/Services/Clipboard/Storage.cpp +++ b/Userland/Services/Clipboard/Storage.cpp @@ -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() diff --git a/Userland/Services/Taskbar/WindowList.cpp b/Userland/Services/Taskbar/WindowList.cpp index eb11240b5d..0af99bf5b0 100644 --- a/Userland/Services/Taskbar/WindowList.cpp +++ b/Userland/Services/Taskbar/WindowList.cpp @@ -8,10 +8,8 @@ WindowList& WindowList::the() { - static WindowList* s_the; - if (!s_the) - s_the = new WindowList; - return *s_the; + static WindowList s_the; + return s_the; } Window* WindowList::find_parent(const Window& window) |