mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:57:44 +00:00
AK+Kernel: Specialize Trie for NNOP<KString> and use it in UnveilNode
This let's us avoid the infallible String allocations.
This commit is contained in:
parent
0218c62be4
commit
316fa0c3f3
6 changed files with 31 additions and 13 deletions
|
@ -11,7 +11,6 @@
|
|||
#include <AK/Function.h>
|
||||
#include <AK/HashTable.h>
|
||||
#include <AK/IntrusiveList.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <Kernel/FileSystem/FIFO.h>
|
||||
#include <Kernel/FileSystem/FileSystem.h>
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <AK/CircularQueue.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <Kernel/API/InodeWatcherEvent.h>
|
||||
#include <Kernel/FileSystem/File.h>
|
||||
#include <Kernel/Forward.h>
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/Trie.h>
|
||||
#include <Kernel/KString.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
|
@ -49,8 +49,8 @@ struct UnveilMetadata {
|
|||
}
|
||||
};
|
||||
|
||||
struct UnveilNode final : public Trie<String, UnveilMetadata, Traits<String>, UnveilNode> {
|
||||
using Trie<String, UnveilMetadata, Traits<String>, UnveilNode>::Trie;
|
||||
struct UnveilNode final : public Trie<NonnullOwnPtr<KString>, UnveilMetadata, Traits<NonnullOwnPtr<KString>>, UnveilNode> {
|
||||
using Trie<NonnullOwnPtr<KString>, UnveilMetadata, Traits<NonnullOwnPtr<KString>>, UnveilNode>::Trie;
|
||||
|
||||
bool was_explicitly_unveiled() const { return this->metadata_value().explicitly_unveiled; }
|
||||
UnveilAccess permissions() const { return this->metadata_value().permissions; }
|
||||
|
|
|
@ -218,7 +218,8 @@ void Process::unprotect_data()
|
|||
ErrorOr<NonnullRefPtr<Process>> Process::try_create(RefPtr<Thread>& first_thread, NonnullOwnPtr<KString> name, UserID uid, GroupID gid, ProcessID ppid, bool is_kernel_process, RefPtr<Custody> cwd, RefPtr<Custody> executable, TTY* tty, Process* fork_parent)
|
||||
{
|
||||
auto space = TRY(Memory::AddressSpace::try_create(fork_parent ? &fork_parent->address_space() : nullptr));
|
||||
auto process = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) Process(move(name), uid, gid, ppid, is_kernel_process, move(cwd), move(executable), tty, UnveilNode { "/"sv, UnveilMetadata(TRY(KString::try_create("/"sv))) })));
|
||||
auto unveil_tree = UnveilNode { TRY(KString::try_create("/"sv)), UnveilMetadata(TRY(KString::try_create("/"sv))) };
|
||||
auto process = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) Process(move(name), uid, gid, ppid, is_kernel_process, move(cwd), move(executable), tty, move(unveil_tree))));
|
||||
TRY(process->attach_resources(move(space), first_thread, fork_parent));
|
||||
return process;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <AK/IntrusiveListRelaxedConst.h>
|
||||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Userspace.h>
|
||||
#include <AK/Variant.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue