Ladybird: Return a reference to the mach server name

Rather than a copy, return a reference so that it's a bit safer to use
the result as a StringView within the calling scope.
This commit is contained in:
Timothy Flynn 2024-04-22 12:56:02 -04:00 committed by Andrew Kaster
parent c7ef8530bf
commit 278fc8e57f
Notes: sideshowbarker 2024-07-17 04:01:41 +09:00
2 changed files with 7 additions and 3 deletions

View file

@ -26,10 +26,14 @@ constexpr auto libexec_path = "libexec"sv;
ByteString s_serenity_resource_root;
Optional<ByteString> s_mach_server_name;
Optional<ByteString> mach_server_name()
Optional<ByteString const&> mach_server_name()
{
return s_mach_server_name;
if (s_mach_server_name.has_value())
return *s_mach_server_name;
return {};
}
void set_mach_server_name(ByteString name)
{
s_mach_server_name = move(name);

View file

@ -17,5 +17,5 @@ ErrorOr<ByteString> application_directory();
ErrorOr<Vector<ByteString>> get_paths_for_helper_process(StringView process_name);
extern ByteString s_serenity_resource_root;
Optional<ByteString> mach_server_name();
Optional<ByteString const&> mach_server_name();
void set_mach_server_name(ByteString name);