Kernel: Convert CommandLine to KString

This commit is contained in:
Idan Horowitz 2022-01-11 21:12:12 +02:00
parent a4560313eb
commit 194d1c884b
Notes: sideshowbarker 2024-07-17 21:04:08 +09:00
2 changed files with 9 additions and 9 deletions

View File

@ -48,7 +48,7 @@ UNMAP_AFTER_INIT void CommandLine::initialize()
}
}
UNMAP_AFTER_INIT void CommandLine::build_commandline(const String& cmdline_from_bootloader)
UNMAP_AFTER_INIT NonnullOwnPtr<KString> CommandLine::build_commandline(StringView cmdline_from_bootloader)
{
StringBuilder builder;
builder.append(cmdline_from_bootloader);
@ -56,7 +56,7 @@ UNMAP_AFTER_INIT void CommandLine::build_commandline(const String& cmdline_from_
builder.append(" ");
builder.append(s_embedded_cmd_line);
}
m_string = builder.to_string();
return KString::must_create(builder.string_view());
}
UNMAP_AFTER_INIT void CommandLine::add_arguments(const Vector<StringView>& args)
@ -77,11 +77,11 @@ UNMAP_AFTER_INIT void CommandLine::add_arguments(const Vector<StringView>& args)
}
}
UNMAP_AFTER_INIT CommandLine::CommandLine(const String& cmdline_from_bootloader)
UNMAP_AFTER_INIT CommandLine::CommandLine(StringView cmdline_from_bootloader)
: m_string(build_commandline(cmdline_from_bootloader))
{
s_the = this;
build_commandline(cmdline_from_bootloader);
const auto& args = m_string.split_view(' ');
const auto& args = m_string->view().split_view(' ');
m_params.ensure_capacity(args.size());
add_arguments(args);
}

View File

@ -58,7 +58,7 @@ public:
BootloaderOnly
};
[[nodiscard]] const String& string() const { return m_string; }
[[nodiscard]] StringView string() const { return m_string->view(); }
Optional<StringView> lookup(StringView key) const;
[[nodiscard]] bool contains(StringView key) const;
@ -89,12 +89,12 @@ public:
[[nodiscard]] size_t switch_to_tty() const;
private:
CommandLine(const String&);
CommandLine(StringView);
void add_arguments(const Vector<StringView>& args);
void build_commandline(const String& cmdline_from_bootloader);
static NonnullOwnPtr<KString> build_commandline(StringView cmdline_from_bootloader);
String m_string;
NonnullOwnPtr<KString> m_string;
HashMap<StringView, StringView> m_params;
};