mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-06 19:22:53 +00:00
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.
This commit is contained in:
parent
fc6d051dfd
commit
7405536a1a
Notes:
sideshowbarker
2024-07-18 11:13:35 +09:00
Author: https://github.com/MaxWipfli
Commit: 7405536a1a
Pull-request: https://github.com/SerenityOS/serenity/pull/8320
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/awesomekling
10 changed files with 98 additions and 79 deletions
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue