diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-06-07 20:58:12 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-06-07 20:58:12 +0200 |
commit | de65c960e9591a5a272d3d4fdc04ec0658dd3566 (patch) | |
tree | e5eb91dc2c97ccd9c498cac383aa31dda6ec8ed9 | |
parent | 736092a0876b115c4131ea114fda81eb52bc3d2e (diff) | |
download | serenity-de65c960e9591a5a272d3d4fdc04ec0658dd3566.zip |
Kernel: Tweak some String&& => const String&.
String&& is just not very practical. Also return const String& when the
returned string is a member variable. The call site is free to make a copy
if he wants, but otherwise we can avoid the retain count churn.
-rw-r--r-- | AK/FileSystemPath.h | 4 | ||||
-rw-r--r-- | Kernel/Process.cpp | 10 | ||||
-rw-r--r-- | Kernel/Process.h | 6 | ||||
-rw-r--r-- | Kernel/SharedMemory.h | 2 | ||||
-rw-r--r-- | Kernel/VM/Region.cpp | 12 | ||||
-rw-r--r-- | Kernel/VM/Region.h | 10 | ||||
-rw-r--r-- | Kernel/VM/VMObject.h | 2 |
7 files changed, 23 insertions, 23 deletions
diff --git a/AK/FileSystemPath.h b/AK/FileSystemPath.h index d985baded1..4e09386ed7 100644 --- a/AK/FileSystemPath.h +++ b/AK/FileSystemPath.h @@ -10,9 +10,9 @@ public: explicit FileSystemPath(const StringView&); bool is_valid() const { return m_is_valid; } - String string() const { return m_string; } + const String& string() const { return m_string; } - String basename() const { return m_basename; } + const String& basename() const { return m_basename; } const Vector<String>& parts() const { return m_parts; } diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 5f9a3bbc5c..7963f3f6df 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -93,7 +93,7 @@ static unsigned prot_to_region_access_flags(int prot) return access; } -Region* Process::allocate_region(VirtualAddress vaddr, size_t size, String&& name, int prot, bool commit) +Region* Process::allocate_region(VirtualAddress vaddr, size_t size, const String& name, int prot, bool commit) { auto range = allocate_range(vaddr, size); if (!range.is_valid()) @@ -105,23 +105,23 @@ Region* Process::allocate_region(VirtualAddress vaddr, size_t size, String&& nam return m_regions.last().ptr(); } -Region* Process::allocate_file_backed_region(VirtualAddress vaddr, size_t size, RetainPtr<Inode>&& inode, String&& name, int prot) +Region* Process::allocate_file_backed_region(VirtualAddress vaddr, size_t size, RetainPtr<Inode>&& inode, const String& name, int prot) { auto range = allocate_range(vaddr, size); if (!range.is_valid()) return nullptr; - m_regions.append(adopt(*new Region(range, move(inode), move(name), prot_to_region_access_flags(prot)))); + m_regions.append(adopt(*new Region(range, move(inode), name, prot_to_region_access_flags(prot)))); MM.map_region(*this, *m_regions.last()); return m_regions.last().ptr(); } -Region* Process::allocate_region_with_vmo(VirtualAddress vaddr, size_t size, Retained<VMObject>&& vmo, size_t offset_in_vmo, String&& name, int prot) +Region* Process::allocate_region_with_vmo(VirtualAddress vaddr, size_t size, Retained<VMObject>&& vmo, size_t offset_in_vmo, const String& name, int prot) { auto range = allocate_range(vaddr, size); if (!range.is_valid()) return nullptr; offset_in_vmo &= PAGE_MASK; - m_regions.append(adopt(*new Region(range, move(vmo), offset_in_vmo, move(name), prot_to_region_access_flags(prot)))); + m_regions.append(adopt(*new Region(range, move(vmo), offset_in_vmo, name, prot_to_region_access_flags(prot)))); MM.map_region(*this, *m_regions.last()); return m_regions.last().ptr(); } diff --git a/Kernel/Process.h b/Kernel/Process.h index 7dbf2e5f5f..0042ca87c8 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -248,9 +248,9 @@ public: bool is_superuser() const { return m_euid == 0; } - Region* allocate_region_with_vmo(VirtualAddress, size_t, Retained<VMObject>&&, size_t offset_in_vmo, String&& name, int prot); - Region* allocate_file_backed_region(VirtualAddress, size_t, RetainPtr<Inode>&&, String&& name, int prot); - Region* allocate_region(VirtualAddress, size_t, String&& name, int prot = PROT_READ | PROT_WRITE, bool commit = true); + Region* allocate_region_with_vmo(VirtualAddress, size_t, Retained<VMObject>&&, size_t offset_in_vmo, const String& name, int prot); + Region* allocate_file_backed_region(VirtualAddress, size_t, RetainPtr<Inode>&&, const String& name, int prot); + Region* allocate_region(VirtualAddress, size_t, const String& name, int prot = PROT_READ | PROT_WRITE, bool commit = true); bool deallocate_region(Region& region); void set_being_inspected(bool b) { m_being_inspected = b; } diff --git a/Kernel/SharedMemory.h b/Kernel/SharedMemory.h index b4a503585a..f7ec96f495 100644 --- a/Kernel/SharedMemory.h +++ b/Kernel/SharedMemory.h @@ -15,7 +15,7 @@ public: static KResult unlink(const String& name); virtual ~SharedMemory() override; - String name() const { return m_name; } + const String& name() const { return m_name; } virtual KResult truncate(off_t) override; VMObject* vmo() { return m_vmo.ptr(); } const VMObject* vmo() const { return m_vmo.ptr(); } diff --git a/Kernel/VM/Region.cpp b/Kernel/VM/Region.cpp index a8c5c8cf35..87acd375d5 100644 --- a/Kernel/VM/Region.cpp +++ b/Kernel/VM/Region.cpp @@ -4,10 +4,10 @@ #include <Kernel/VM/Region.h> #include <Kernel/VM/VMObject.h> -Region::Region(const Range& range, String&& n, byte access, bool cow) +Region::Region(const Range& range, const String& name, byte access, bool cow) : m_range(range) , m_vmo(VMObject::create_anonymous(size())) - , m_name(move(n)) + , m_name(name) , m_access(access) , m_cow_map(Bitmap::create(m_vmo->page_count(), cow)) { @@ -15,21 +15,21 @@ Region::Region(const Range& range, String&& n, byte access, bool cow) MM.register_region(*this); } -Region::Region(const Range& range, RetainPtr<Inode>&& inode, String&& n, byte access) +Region::Region(const Range& range, RetainPtr<Inode>&& inode, const String& name, byte access) : m_range(range) , m_vmo(VMObject::create_file_backed(move(inode))) - , m_name(move(n)) + , m_name(name) , m_access(access) , m_cow_map(Bitmap::create(m_vmo->page_count())) { MM.register_region(*this); } -Region::Region(const Range& range, Retained<VMObject>&& vmo, size_t offset_in_vmo, String&& n, byte access, bool cow) +Region::Region(const Range& range, Retained<VMObject>&& vmo, size_t offset_in_vmo, const String& name, byte access, bool cow) : m_range(range) , m_offset_in_vmo(offset_in_vmo) , m_vmo(move(vmo)) - , m_name(move(n)) + , m_name(name) , m_access(access) , m_cow_map(Bitmap::create(m_vmo->page_count(), cow)) { diff --git a/Kernel/VM/Region.h b/Kernel/VM/Region.h index 8480ce03cd..ef094bc0b6 100644 --- a/Kernel/VM/Region.h +++ b/Kernel/VM/Region.h @@ -18,9 +18,9 @@ public: Execute = 4, }; - Region(const Range&, String&&, byte access, bool cow = false); - Region(const Range&, Retained<VMObject>&&, size_t offset_in_vmo, String&&, byte access, bool cow = false); - Region(const Range&, RetainPtr<Inode>&&, String&&, byte access); + Region(const Range&, const String&, byte access, bool cow = false); + Region(const Range&, Retained<VMObject>&&, size_t offset_in_vmo, const String&, byte access, bool cow = false); + Region(const Range&, RetainPtr<Inode>&&, const String&, byte access); ~Region(); VirtualAddress vaddr() const { return m_range.base(); } @@ -28,9 +28,9 @@ public: bool is_readable() const { return m_access & Access::Read; } bool is_writable() const { return m_access & Access::Write; } bool is_executable() const { return m_access & Access::Execute; } - String name() const { return m_name; } + const String& name() const { return m_name; } - void set_name(String&& name) { m_name = move(name); } + void set_name(const String& name) { m_name = name; } const VMObject& vmo() const { return *m_vmo; } VMObject& vmo() { return *m_vmo; } diff --git a/Kernel/VM/VMObject.h b/Kernel/VM/VMObject.h index 0f7b9c4fea..6d69ac06ec 100644 --- a/Kernel/VM/VMObject.h +++ b/Kernel/VM/VMObject.h @@ -30,7 +30,7 @@ public: const Inode* inode() const { return m_inode.ptr(); } size_t inode_offset() const { return m_inode_offset; } - String name() const { return m_name; } + const String& name() const { return m_name; } void set_name(const String& name) { m_name = name; } size_t page_count() const { return m_size / PAGE_SIZE; } |