From f4b345258d108defa3a92c2164fddaf0daa22b77 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Tue, 23 Jan 2024 16:37:29 +0000 Subject: [PATCH] tar: Remove unnecessary conversions to String We use these canonicalized_path variables as StringViews, so it doesn't matter if they are a String or ByteString. And they're paths so shouldn't be String anyway. --- Userland/Utilities/tar.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Userland/Utilities/tar.cpp b/Userland/Utilities/tar.cpp index 1f434f8c33..89b7d04d10 100644 --- a/Userland/Utilities/tar.cpp +++ b/Userland/Utilities/tar.cpp @@ -251,7 +251,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto file = file_or_error.release_value(); auto statbuf = TRY(Core::System::lstat(path)); - auto canonicalized_path = TRY(String::from_byte_string(LexicalPath::canonicalized_path(path))); + auto canonicalized_path = LexicalPath::canonicalized_path(path); // FIXME: We should stream instead of reading the entire file in one go, but TarOutputStream does not have any interface to do so. auto file_content = TRY(file->read_until_eof()); TRY(tar_stream.add_file(canonicalized_path, statbuf.st_mode, file_content)); @@ -264,7 +264,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto add_link = [&](ByteString path) -> ErrorOr { auto statbuf = TRY(Core::System::lstat(path)); - auto canonicalized_path = TRY(String::from_byte_string(LexicalPath::canonicalized_path(path))); + auto canonicalized_path = LexicalPath::canonicalized_path(path); TRY(tar_stream.add_link(canonicalized_path, statbuf.st_mode, TRY(Core::System::readlink(path)))); if (verbose) outln("{}", canonicalized_path); @@ -275,7 +275,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto add_directory = [&](ByteString path, auto handle_directory) -> ErrorOr { auto statbuf = TRY(Core::System::lstat(path)); - auto canonicalized_path = TRY(String::from_byte_string(LexicalPath::canonicalized_path(path))); + auto canonicalized_path = LexicalPath::canonicalized_path(path); TRY(tar_stream.add_directory(canonicalized_path, statbuf.st_mode)); if (verbose) outln("{}", canonicalized_path);