diff options
author | Max Wipfli <mail@maxwipfli.ch> | 2021-06-29 17:06:21 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-30 11:13:54 +0200 |
commit | 7405536a1abcc23d6a54565687800b14bde3db53 (patch) | |
tree | bb3e3affb873a170eebfb6d08a3abae9b08d4ffc /Kernel/FileSystem/VirtualFileSystem.cpp | |
parent | fc6d051dfdddc13835548537d025e760ba186b5b (diff) | |
download | serenity-7405536a1abcc23d6a54565687800b14bde3db53.zip |
AK+Everywhere: Use mostly StringView in LexicalPath
This changes the m_parts, m_dirname, m_basename, m_title and m_extension
member variables to StringViews onto the m_string String. It also
removes the m_is_absolute member in favour of computing if a path is
absolute in the is_absolute() getter. Due to this, the canonicalize()
method has been completely rewritten.
The parts() getter still returns a Vector<String>, although it is no
longer a const reference as m_parts is no longer a Vector<String>.
Rather, it is constructed from the StringViews in m_parts upon request.
The parts_view() getter has been added, which returns Vector<StringView>
const&. Most previous users of parts() have been changed to use
parts_view(), except where Strings are required.
Due to this change, it's is now no longer allow to create temporary
LexicalPath objects to call the dirname, basename, title, or extension
getters on them because the returned StringViews will point to possible
freed memory.
Diffstat (limited to 'Kernel/FileSystem/VirtualFileSystem.cpp')
-rw-r--r-- | Kernel/FileSystem/VirtualFileSystem.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp index 1002b9f67b..a6341df577 100644 --- a/Kernel/FileSystem/VirtualFileSystem.cpp +++ b/Kernel/FileSystem/VirtualFileSystem.cpp @@ -834,7 +834,7 @@ UnveilNode const& VFS::find_matching_unveiled_path(StringView path) auto& unveil_root = Process::current()->unveiled_paths(); LexicalPath lexical_path { path }; - auto& path_parts = lexical_path.parts(); + auto& path_parts = lexical_path.parts_view(); return unveil_root.traverse_until_last_accessible_node(path_parts.begin(), path_parts.end()); } |