Преглед изворни кода

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. :^)
Andreas Kling пре 6 година
родитељ
комит
93489fbc4c

+ 1 - 1
Applications/ProcessManager/ProcessModel.h

@@ -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;

+ 1 - 1
Applications/Taskbar/WindowList.h

@@ -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;
 };

+ 3 - 3
Kernel/SharedBuffer.cpp

@@ -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;
 }
 

+ 1 - 1
Kernel/SharedBuffer.h

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

+ 2 - 2
Libraries/LibCore/CEventLoop.cpp

@@ -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*>;
     }
 

+ 1 - 1
Libraries/LibCore/CEventLoop.h

@@ -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;

+ 1 - 1
Libraries/LibGUI/GTreeView.h

@@ -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;

+ 3 - 3
Servers/WindowServer/WSClientConnection.h

@@ -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 };