Sfoglia il codice sorgente

Kernel: Tidy up ProcessProcFSTraits construction a bit more

Let the constructor take a Process& instead of a WeakPtr<Process> and
avoid a bunch of WeakPtr copying.
Andreas Kling 3 anni fa
parent
commit
db2e67fd53
2 ha cambiato i file con 4 aggiunte e 4 eliminazioni
  1. 1 1
      Kernel/Process.cpp
  2. 3 3
      Kernel/Process.h

+ 1 - 1
Kernel/Process.cpp

@@ -268,7 +268,7 @@ KResult Process::attach_resources(NonnullOwnPtr<Memory::AddressSpace>&& prealloc
         first_thread->detach();
         first_thread->detach();
     }
     }
 
 
-    m_procfs_traits = TRY(ProcessProcFSTraits::try_create({}, make_weak_ptr()));
+    m_procfs_traits = TRY(ProcessProcFSTraits::try_create({}, *this));
     return KSuccess;
     return KSuccess;
 }
 }
 
 

+ 3 - 3
Kernel/Process.h

@@ -718,7 +718,7 @@ public:
 
 
     class ProcessProcFSTraits : public ProcFSExposedComponent {
     class ProcessProcFSTraits : public ProcFSExposedComponent {
     public:
     public:
-        static KResultOr<NonnullRefPtr<ProcessProcFSTraits>> try_create(Badge<Process>, WeakPtr<Process> process)
+        static KResultOr<NonnullRefPtr<ProcessProcFSTraits>> try_create(Badge<Process>, Process& process)
         {
         {
             return adopt_nonnull_ref_or_enomem(new (nothrow) ProcessProcFSTraits(process));
             return adopt_nonnull_ref_or_enomem(new (nothrow) ProcessProcFSTraits(process));
         }
         }
@@ -732,8 +732,8 @@ public:
         virtual GroupID owner_group() const override;
         virtual GroupID owner_group() const override;
 
 
     private:
     private:
-        ProcessProcFSTraits(WeakPtr<Process> process)
-            : m_process(process)
+        explicit ProcessProcFSTraits(Process& process)
+            : m_process(process.make_weak_ptr())
         {
         {
         }
         }