mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-02 04:20:28 +00:00
Refactor: Replace usages of FixedArray with Vector.
This commit is contained in:
parent
9c83d6ff46
commit
ec1080b18a
Notes:
sideshowbarker
2024-07-19 02:50:02 +09:00
Author: https://github.com/asynts Commit: https://github.com/SerenityOS/serenity/commit/ec1080b18ad Pull-request: https://github.com/SerenityOS/serenity/pull/3426
9 changed files with 27 additions and 23 deletions
|
@ -174,6 +174,15 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
bool contains_slow(const T& value) const
|
||||
{
|
||||
for (size_t i = 0; i < size(); ++i) {
|
||||
if (at(i) == value)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE const T& at(size_t index) const
|
||||
{
|
||||
ASSERT(index < this->m_size);
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/FixedArray.h>
|
||||
#include <AK/Span.h>
|
||||
#include <Kernel/FileSystem/InodeIdentifier.h>
|
||||
#include <Kernel/KResult.h>
|
||||
#include <Kernel/UnixTypes.h>
|
||||
|
@ -58,35 +58,35 @@ struct InodeMetadata {
|
|||
bool may_write(const Process&) const;
|
||||
bool may_execute(const Process&) const;
|
||||
|
||||
bool may_read(uid_t u, gid_t g, const FixedArray<gid_t>& eg) const
|
||||
bool may_read(uid_t u, gid_t g, Span<const gid_t> eg) const
|
||||
{
|
||||
if (u == 0)
|
||||
return true;
|
||||
if (uid == u)
|
||||
return mode & S_IRUSR;
|
||||
if (gid == g || eg.contains(gid))
|
||||
if (gid == g || eg.contains_slow(gid))
|
||||
return mode & S_IRGRP;
|
||||
return mode & S_IROTH;
|
||||
}
|
||||
|
||||
bool may_write(uid_t u, gid_t g, const FixedArray<gid_t>& eg) const
|
||||
bool may_write(uid_t u, gid_t g, Span<const gid_t> eg) const
|
||||
{
|
||||
if (u == 0)
|
||||
return true;
|
||||
if (uid == u)
|
||||
return mode & S_IWUSR;
|
||||
if (gid == g || eg.contains(gid))
|
||||
if (gid == g || eg.contains_slow(gid))
|
||||
return mode & S_IWGRP;
|
||||
return mode & S_IWOTH;
|
||||
}
|
||||
|
||||
bool may_execute(uid_t u, gid_t g, const FixedArray<gid_t>& eg) const
|
||||
bool may_execute(uid_t u, gid_t g, Span<const gid_t> eg) const
|
||||
{
|
||||
if (u == 0)
|
||||
return true;
|
||||
if (uid == u)
|
||||
return mode & S_IXUSR;
|
||||
if (gid == g || eg.contains(gid))
|
||||
if (gid == g || eg.contains_slow(gid))
|
||||
return mode & S_IXGRP;
|
||||
return mode & S_IXOTH;
|
||||
}
|
||||
|
|
|
@ -137,6 +137,7 @@ PhysicalAddress InterruptManagement::search_for_madt()
|
|||
InterruptManagement::InterruptManagement()
|
||||
: m_madt(search_for_madt())
|
||||
{
|
||||
m_interrupt_controllers.resize(1);
|
||||
}
|
||||
|
||||
void InterruptManagement::switch_to_pic_mode()
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/FixedArray.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
|
@ -89,7 +88,7 @@ private:
|
|||
PhysicalAddress search_for_madt();
|
||||
void locate_apic_data();
|
||||
bool m_smp_enabled { false };
|
||||
FixedArray<RefPtr<IRQController>> m_interrupt_controllers { 1 };
|
||||
Vector<RefPtr<IRQController>> m_interrupt_controllers;
|
||||
Vector<ISAInterruptOverrideMetadata> m_isa_interrupt_overrides;
|
||||
Vector<PCIInterruptOverrideMetadata> m_pci_interrupt_overrides;
|
||||
PhysicalAddress m_madt;
|
||||
|
|
|
@ -142,7 +142,7 @@ NonnullRefPtrVector<Process> Process::all_processes()
|
|||
|
||||
bool Process::in_group(gid_t gid) const
|
||||
{
|
||||
return m_gid == gid || m_extra_gids.contains(gid);
|
||||
return m_gid == gid || m_extra_gids.contains_slow(gid);
|
||||
}
|
||||
|
||||
Range Process::allocate_range(VirtualAddress vaddr, size_t size, size_t alignment)
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Checked.h>
|
||||
#include <AK/FixedArray.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/InlineLinkedList.h>
|
||||
#include <AK/NonnullOwnPtrVector.h>
|
||||
|
@ -162,7 +161,7 @@ public:
|
|||
bool is_session_leader() const { return m_sid.value() == m_pid.value(); }
|
||||
ProcessGroupID pgid() const { return m_pg ? m_pg->pgid() : 0; }
|
||||
bool is_group_leader() const { return pgid().value() == m_pid.value(); }
|
||||
const FixedArray<gid_t>& extra_gids() const { return m_extra_gids; }
|
||||
Span<const gid_t> extra_gids() const { return m_extra_gids; }
|
||||
uid_t euid() const { return m_euid; }
|
||||
gid_t egid() const { return m_egid; }
|
||||
uid_t uid() const { return m_uid; }
|
||||
|
@ -683,7 +682,7 @@ private:
|
|||
ProcessID m_ppid { 0 };
|
||||
mode_t m_umask { 022 };
|
||||
|
||||
FixedArray<gid_t> m_extra_gids;
|
||||
Vector<gid_t> m_extra_gids;
|
||||
|
||||
WeakPtr<Region> m_master_tls_region;
|
||||
size_t m_master_tls_size { 0 };
|
||||
|
|
|
@ -86,11 +86,7 @@ int Process::sys$getgroups(ssize_t count, Userspace<gid_t*> user_gids)
|
|||
if (!validate_write_typed(user_gids, m_extra_gids.size()))
|
||||
return -EFAULT;
|
||||
|
||||
Vector<gid_t> gids;
|
||||
for (auto gid : m_extra_gids)
|
||||
gids.append(gid);
|
||||
|
||||
copy_to_user(user_gids, gids.data(), sizeof(gid_t) * count);
|
||||
copy_to_user(user_gids, m_extra_gids.data(), sizeof(gid_t) * count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@ VMObject::VMObject(const VMObject& other)
|
|||
}
|
||||
|
||||
VMObject::VMObject(size_t size)
|
||||
: m_physical_pages(ceil_div(size, PAGE_SIZE))
|
||||
{
|
||||
m_physical_pages.resize(ceil_div(size, PAGE_SIZE));
|
||||
MM.register_vmobject(*this);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/FixedArray.h>
|
||||
#include <AK/InlineLinkedList.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <Kernel/Lock.h>
|
||||
|
||||
|
@ -58,8 +58,8 @@ public:
|
|||
virtual bool is_contiguous() const { return false; }
|
||||
|
||||
size_t page_count() const { return m_physical_pages.size(); }
|
||||
const FixedArray<RefPtr<PhysicalPage>>& physical_pages() const { return m_physical_pages; }
|
||||
FixedArray<RefPtr<PhysicalPage>>& physical_pages() { return m_physical_pages; }
|
||||
const Vector<RefPtr<PhysicalPage>>& physical_pages() const { return m_physical_pages; }
|
||||
Vector<RefPtr<PhysicalPage>>& physical_pages() { return m_physical_pages; }
|
||||
|
||||
size_t size() const { return m_physical_pages.size() * PAGE_SIZE; }
|
||||
|
||||
|
@ -76,7 +76,7 @@ protected:
|
|||
template<typename Callback>
|
||||
void for_each_region(Callback);
|
||||
|
||||
FixedArray<RefPtr<PhysicalPage>> m_physical_pages;
|
||||
Vector<RefPtr<PhysicalPage>> m_physical_pages;
|
||||
Lock m_paging_lock { "VMObject" };
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue