1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 13:27:36 +00:00

Everywhere: Add sv suffix to strings relying on StringView(char const*)

Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
This commit is contained in:
sin-ack 2022-07-11 17:32:29 +00:00 committed by Andreas Kling
parent e5f09ea170
commit 3f3f45580a
762 changed files with 8315 additions and 8316 deletions

View file

@ -24,7 +24,7 @@ static ELF::Image* try_load_kernel_binary()
{
if (s_kernel_binary.has_value())
return &s_kernel_binary->elf;
auto kernel_binary_or_error = Core::MappedFile::map("/boot/Kernel");
auto kernel_binary_or_error = Core::MappedFile::map("/boot/Kernel"sv);
if (!kernel_binary_or_error.is_error()) {
auto kernel_binary = kernel_binary_or_error.release_value();
s_kernel_binary = { { kernel_binary, ELF::Image(kernel_binary->bytes()) } };
@ -212,12 +212,12 @@ GUI::Variant DisassemblyModel::data(GUI::ModelIndex const& index, GUI::ModelRole
if (first)
first = false;
else
builder.append(" => ");
builder.append(" => "sv);
builder.appendff("{}:{}", entry.file_path, entry.line_number);
}
if (insn.source_position_with_inlines.source_position.has_value()) {
if (!first)
builder.append(" => ");
builder.append(" => "sv);
auto const& entry = insn.source_position_with_inlines.source_position.value();
builder.appendff("{}:{}", entry.file_path, entry.line_number);
}

View file

@ -245,7 +245,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
auto const& object = json.value().as_object();
if (!g_kernel_debuginfo_object.has_value()) {
auto debuginfo_file_or_error = Core::MappedFile::map("/boot/Kernel.debug");
auto debuginfo_file_or_error = Core::MappedFile::map("/boot/Kernel.debug"sv);
if (!debuginfo_file_or_error.is_error()) {
auto debuginfo_file = debuginfo_file_or_error.release_value();
auto debuginfo_image = ELF::Image(debuginfo_file->bytes());
@ -263,7 +263,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
profile_strings.set(string_id, value.to_string());
}
auto const* events_value = object.get_ptr("events");
auto const* events_value = object.get_ptr("events"sv);
if (!events_value || !events_value->is_array())
return Error::from_string_literal("Malformed profile (events is not an array)");
@ -281,12 +281,12 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
event.serial = next_serial;
next_serial.increment();
event.timestamp = perf_event.get("timestamp").to_number<u64>();
event.lost_samples = perf_event.get("lost_samples").to_number<u32>();
event.pid = perf_event.get("pid").to_i32();
event.tid = perf_event.get("tid").to_i32();
event.timestamp = perf_event.get("timestamp"sv).to_number<u64>();
event.lost_samples = perf_event.get("lost_samples"sv).to_number<u32>();
event.pid = perf_event.get("pid"sv).to_i32();
event.tid = perf_event.get("tid"sv).to_i32();
auto type_string = perf_event.get("type").to_string();
auto type_string = perf_event.get("type"sv).to_string();
if (type_string == "sample"sv) {
event.data = Event::SampleData {};
@ -403,7 +403,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
auto maybe_kernel_base = Symbolication::kernel_base();
auto const* stack = perf_event.get_ptr("stack");
auto const* stack = perf_event.get_ptr("stack"sv);
VERIFY(stack);
auto const& stack_array = stack->as_array();
for (ssize_t i = stack_array.values().size() - 1; i >= 0; --i) {

View file

@ -16,8 +16,8 @@ namespace Profiler {
ProfileModel::ProfileModel(Profile& profile)
: m_profile(profile)
{
m_user_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png").release_value_but_fixme_should_propagate_errors());
m_kernel_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object-red.png").release_value_but_fixme_should_propagate_errors());
m_user_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png"sv).release_value_but_fixme_should_propagate_errors());
m_kernel_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object-red.png"sv).release_value_but_fixme_should_propagate_errors());
}
GUI::ModelIndex ProfileModel::index(int row, int column, GUI::ModelIndex const& parent) const

View file

@ -14,8 +14,8 @@ namespace Profiler {
SamplesModel::SamplesModel(Profile& profile)
: m_profile(profile)
{
m_user_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png").release_value_but_fixme_should_propagate_errors());
m_kernel_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object-red.png").release_value_but_fixme_should_propagate_errors());
m_user_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png"sv).release_value_but_fixme_should_propagate_errors());
m_kernel_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object-red.png"sv).release_value_but_fixme_should_propagate_errors());
}
int SamplesModel::row_count(GUI::ModelIndex const&) const

View file

@ -27,7 +27,7 @@ public:
public:
SourceFile(StringView filename)
{
String source_file_name = filename.replace("../../", source_root_path, ReplaceMode::FirstOnly);
String source_file_name = filename.replace("../../"sv, source_root_path, ReplaceMode::FirstOnly);
auto maybe_file = Core::File::open(source_file_name, Core::OpenMode::ReadOnly);
if (maybe_file.is_error()) {

View file

@ -58,7 +58,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
auto app = TRY(GUI::Application::try_create(arguments));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-profiler"));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-profiler"sv));
String perfcore_file;
if (!perfcore_file_arg) {
@ -71,7 +71,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto profile_or_error = Profile::load_from_perfcore_file(perfcore_file);
if (profile_or_error.is_error()) {
GUI::MessageBox::show(nullptr, String::formatted("{}", profile_or_error.error()), "Profiler", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(nullptr, String::formatted("{}", profile_or_error.error()), "Profiler"sv, GUI::MessageBox::Type::Error);
return 0;
}
@ -170,12 +170,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
update_source_model();
};
auto disassembly_action = GUI::Action::create_checkable("Show &Disassembly", { Mod_Ctrl, Key_D }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/x86.png").release_value_but_fixme_should_propagate_errors(), [&](auto& action) {
auto disassembly_action = GUI::Action::create_checkable("Show &Disassembly", { Mod_Ctrl, Key_D }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/x86.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto& action) {
disassembly_view->set_visible(action.is_checked());
update_disassembly_model();
});
auto source_action = GUI::Action::create_checkable("Show &Source", { Mod_Ctrl, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/x86.png").release_value_but_fixme_should_propagate_errors(), [&](auto& action) {
auto source_action = GUI::Action::create_checkable("Show &Source", { Mod_Ctrl, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/x86.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto& action) {
source_view->set_visible(action.is_checked());
update_source_model();
});
@ -314,7 +314,7 @@ static bool prompt_to_stop_profiling(pid_t pid, String const& process_name)
auto window = GUI::Window::construct();
window->set_title(String::formatted("Profiling {}({})", process_name, pid));
window->resize(240, 100);
window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-profiler.png").release_value_but_fixme_should_propagate_errors());
window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-profiler.png"sv).release_value_but_fixme_should_propagate_errors());
window->center_on_screen();
auto& widget = window->set_main_widget<GUI::Widget>();
@ -342,7 +342,7 @@ static bool prompt_to_stop_profiling(pid_t pid, String const& process_name)
bool generate_profile(pid_t& pid)
{
if (!pid) {
auto process_chooser = GUI::ProcessChooser::construct("Profiler", "Profile", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-profiler.png").release_value_but_fixme_should_propagate_errors());
auto process_chooser = GUI::ProcessChooser::construct("Profiler"sv, "Profile"sv, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-profiler.png"sv).release_value_but_fixme_should_propagate_errors());
if (process_chooser->exec() == GUI::Dialog::ExecResult::Cancel)
return false;
pid = process_chooser->pid();
@ -366,7 +366,7 @@ bool generate_profile(pid_t& pid)
if (profiling_enable(pid, event_mask) < 0) {
int saved_errno = errno;
GUI::MessageBox::show(nullptr, String::formatted("Unable to profile process {}({}): {}", process_name, pid, strerror(saved_errno)), "Profiler", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(nullptr, String::formatted("Unable to profile process {}({}): {}", process_name, pid, strerror(saved_errno)), "Profiler"sv, GUI::MessageBox::Type::Error);
return false;
}