mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 01:41:59 -05:00
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.
This commit is contained in:
parent
736092a087
commit
de65c960e9
7 changed files with 23 additions and 23 deletions
|
@ -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; }
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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(); }
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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; }
|
||||
|
|
Loading…
Reference in a new issue