Convert HashMap<Key, OwnPtr<T>> to HashMap<Key, NonnullOwnPtr<T>>.

In every case I found, we never wanted to support null entry values.
With NonnullOwnPtr, we can encode that at the type level. :^)
This commit is contained in:
Andreas Kling 2019-07-24 08:42:55 +02:00
parent 3c5befde36
commit 93489fbc4c
Notes: sideshowbarker 2024-07-19 13:04:39 +09:00
8 changed files with 13 additions and 13 deletions

View file

@ -58,7 +58,7 @@ private:
};
HashMap<uid_t, String> m_usernames;
HashMap<pid_t, OwnPtr<Process>> m_processes;
HashMap<pid_t, NonnullOwnPtr<Process>> m_processes;
Vector<pid_t> m_pids;
RefPtr<GraphicsBitmap> m_generic_process_icon;
RefPtr<GraphicsBitmap> m_high_priority_icon;

View file

@ -78,5 +78,5 @@ public:
Function<GButton*(const WindowIdentifier&)> aid_create_button;
private:
HashMap<WindowIdentifier, OwnPtr<Window>> m_windows;
HashMap<WindowIdentifier, NonnullOwnPtr<Window>> m_windows;
};

View file

@ -1,11 +1,11 @@
#include <Kernel/SharedBuffer.h>
#include <Kernel/Process.h>
Lockable<HashMap<int, OwnPtr<SharedBuffer>>>& shared_buffers()
Lockable<HashMap<int, NonnullOwnPtr<SharedBuffer>>>& shared_buffers()
{
static Lockable<HashMap<int, OwnPtr<SharedBuffer>>>* map;
static Lockable<HashMap<int, NonnullOwnPtr<SharedBuffer>>>* map;
if (!map)
map = new Lockable<HashMap<int, OwnPtr<SharedBuffer>>>;
map = new Lockable<HashMap<int, NonnullOwnPtr<SharedBuffer>>>;
return *map;
}

View file

@ -49,4 +49,4 @@ public:
unsigned m_total_refs { 0 };
};
Lockable<HashMap<int, OwnPtr<SharedBuffer>>>& shared_buffers();
Lockable<HashMap<int, NonnullOwnPtr<SharedBuffer>>>& shared_buffers();

View file

@ -21,7 +21,7 @@
static CEventLoop* s_main_event_loop;
static Vector<CEventLoop*>* s_event_loop_stack;
HashMap<int, OwnPtr<CEventLoop::EventLoopTimer>>* CEventLoop::s_timers;
HashMap<int, NonnullOwnPtr<CEventLoop::EventLoopTimer>>* CEventLoop::s_timers;
HashTable<CNotifier*>* CEventLoop::s_notifiers;
int CEventLoop::s_next_timer_id = 1;
int CEventLoop::s_wake_pipe_fds[2];
@ -30,7 +30,7 @@ CEventLoop::CEventLoop()
{
if (!s_event_loop_stack) {
s_event_loop_stack = new Vector<CEventLoop*>;
s_timers = new HashMap<int, OwnPtr<CEventLoop::EventLoopTimer>>;
s_timers = new HashMap<int, NonnullOwnPtr<CEventLoop::EventLoopTimer>>;
s_notifiers = new HashTable<CNotifier*>;
}

View file

@ -81,7 +81,7 @@ private:
bool has_expired(const timeval& now) const;
};
static HashMap<int, OwnPtr<EventLoopTimer>>* s_timers;
static HashMap<int, NonnullOwnPtr<EventLoopTimer>>* s_timers;
static int s_next_timer_id;
static HashTable<CNotifier*>* s_notifiers;

View file

@ -35,7 +35,7 @@ private:
MetadataForIndex& ensure_metadata_for_index(const GModelIndex&) const;
mutable HashMap<void*, OwnPtr<MetadataForIndex>> m_view_metadata;
mutable HashMap<void*, NonnullOwnPtr<MetadataForIndex>> m_view_metadata;
RefPtr<GraphicsBitmap> m_expand_bitmap;
RefPtr<GraphicsBitmap> m_collapse_bitmap;

View file

@ -78,9 +78,9 @@ private:
void post_error(const String&);
HashMap<int, OwnPtr<WSWindow>> m_windows;
HashMap<int, OwnPtr<WSMenuBar>> m_menubars;
HashMap<int, OwnPtr<WSMenu>> m_menus;
HashMap<int, NonnullOwnPtr<WSWindow>> m_windows;
HashMap<int, NonnullOwnPtr<WSMenuBar>> m_menubars;
HashMap<int, NonnullOwnPtr<WSMenu>> m_menus;
WeakPtr<WSMenuBar> m_app_menubar;
int m_next_menubar_id { 10000 };