summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/EmojiInputDialog.cpp
diff options
context:
space:
mode:
authorMax Wipfli <mail@maxwipfli.ch>2021-06-29 17:06:21 +0200
committerAndreas Kling <kling@serenityos.org>2021-06-30 11:13:54 +0200
commit7405536a1abcc23d6a54565687800b14bde3db53 (patch)
treebb3e3affb873a170eebfb6d08a3abae9b08d4ffc /Userland/Libraries/LibGUI/EmojiInputDialog.cpp
parentfc6d051dfdddc13835548537d025e760ba186b5b (diff)
downloadserenity-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 'Userland/Libraries/LibGUI/EmojiInputDialog.cpp')
-rw-r--r--Userland/Libraries/LibGUI/EmojiInputDialog.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibGUI/EmojiInputDialog.cpp b/Userland/Libraries/LibGUI/EmojiInputDialog.cpp
index 098a2ce1ab..7a25e701c3 100644
--- a/Userland/Libraries/LibGUI/EmojiInputDialog.cpp
+++ b/Userland/Libraries/LibGUI/EmojiInputDialog.cpp
@@ -26,10 +26,10 @@ static Vector<u32> supported_emoji_code_points()
auto lexical_path = LexicalPath(filename);
if (lexical_path.extension() != "png")
continue;
- auto basename = lexical_path.basename();
+ auto& basename = lexical_path.basename();
if (!basename.starts_with("U+"))
continue;
- u32 code_point = strtoul(basename.characters() + 2, nullptr, 16);
+ u32 code_point = strtoul(basename.to_string().characters() + 2, nullptr, 16);
code_points.append(code_point);
}
return code_points;