From a3eeeaa6a1079fc17e0f81e4453560231b52cca0 Mon Sep 17 00:00:00 2001 From: sin-ack Date: Mon, 11 Jul 2022 20:44:47 +0000 Subject: [PATCH] Userland: Remove erroneous String -> char* -> StringView conversions These were accidental (or leftover) uses of String::characters() to construct StringViews through its StringView(char const*) constructor. Since this constructor is due to be removed, this will no longer work. Plus this prevents strlen from being run on these strings unnecessarily. --- Userland/DevTools/UserspaceEmulator/Emulator.cpp | 2 +- Userland/Libraries/LibCore/Process.cpp | 2 +- Userland/Utilities/du.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.cpp b/Userland/DevTools/UserspaceEmulator/Emulator.cpp index e34157abce..e78ba56772 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator.cpp +++ b/Userland/DevTools/UserspaceEmulator/Emulator.cpp @@ -113,7 +113,7 @@ void Emulator::setup_stack(Vector aux_vector) Vector env_entries; for (auto const& variable : m_environment) { - m_cpu->push_string(variable.characters()); + m_cpu->push_string(variable.view()); env_entries.append(m_cpu->esp().value()); } diff --git a/Userland/Libraries/LibCore/Process.cpp b/Userland/Libraries/LibCore/Process.cpp index afa5fb1a3a..a7c5747dc6 100644 --- a/Userland/Libraries/LibCore/Process.cpp +++ b/Userland/Libraries/LibCore/Process.cpp @@ -45,7 +45,7 @@ struct ArgvList { ErrorOr spawn() { - auto pid = TRY(System::posix_spawn(m_path.characters(), nullptr, nullptr, const_cast(get().data()), environ)); + auto pid = TRY(System::posix_spawn(m_path.view(), nullptr, nullptr, const_cast(get().data()), environ)); #ifdef __serenity__ TRY(System::disown(pid)); #endif diff --git a/Userland/Utilities/du.cpp b/Userland/Utilities/du.cpp index 00c039b63d..28229f6e55 100644 --- a/Userland/Utilities/du.cpp +++ b/Userland/Utilities/du.cpp @@ -120,7 +120,7 @@ ErrorOr parse_args(Main::Arguments arguments, Vector& files, DuOpt ErrorOr print_space_usage(String const& path, DuOption const& du_option, int max_depth, bool inside_dir) { - struct stat path_stat = TRY(Core::System::lstat(path.characters())); + struct stat path_stat = TRY(Core::System::lstat(path)); off_t directory_size = 0; bool const is_directory = S_ISDIR(path_stat.st_mode); if (--max_depth >= 0 && is_directory) {