1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 05:44:58 +00:00

StringViewize a bunch of things -- mostly LibGUI

This commit is contained in:
Robin Burchell 2019-06-02 14:58:02 +02:00 committed by Andreas Kling
parent f9ba7adae2
commit 1024dfa81a
59 changed files with 129 additions and 139 deletions

View file

@ -9,11 +9,10 @@
namespace AK {
MappedFile::MappedFile(const String& file_name)
: m_file_name(file_name)
MappedFile::MappedFile(const StringView& file_name)
{
m_size = PAGE_SIZE;
m_fd = open(m_file_name.characters(), O_RDONLY | O_CLOEXEC);
m_fd = open(file_name.characters(), O_RDONLY | O_CLOEXEC);
if (m_fd != -1) {
struct stat st;
@ -26,7 +25,7 @@ MappedFile::MappedFile(const String& file_name)
}
#ifdef DEBUG_MAPPED_FILE
dbgprintf("MappedFile{%s} := { m_fd=%d, m_size=%u, m_map=%p }\n", m_file_name.characters(), m_fd, m_size, m_map);
dbgprintf("MappedFile{%s} := { m_fd=%d, m_size=%u, m_map=%p }\n", file_name.characters(), m_fd, m_size, m_map);
#endif
}
@ -44,15 +43,13 @@ void MappedFile::unmap()
ASSERT(rc == 0);
rc = close(m_fd);
ASSERT(rc == 0);
m_file_name = {};
m_size = 0;
m_fd = -1;
m_map = (void*)-1;
}
MappedFile::MappedFile(MappedFile&& other)
: m_file_name(move(other.m_file_name))
, m_size(other.m_size)
: m_size(other.m_size)
, m_fd(other.m_fd)
, m_map(other.m_map)
{
@ -66,7 +63,6 @@ MappedFile& MappedFile::operator=(MappedFile&& other)
if (this == &other)
return *this;
unmap();
swap(m_file_name, other.m_file_name);
swap(m_size, other.m_size);
swap(m_fd, other.m_fd);
swap(m_map, other.m_map);