1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 05:27:45 +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

@ -74,19 +74,19 @@ TEST_CASE(file_permission_mask_from_symbolic_notation)
mask = Core::FilePermissionsMask::from_symbolic_notation("z+rw"sv);
EXPECT(mask.is_error());
EXPECT(mask.error().string_literal().starts_with("invalid class"));
EXPECT(mask.error().string_literal().starts_with("invalid class"sv));
mask = Core::FilePermissionsMask::from_symbolic_notation("u*rw"sv);
EXPECT(mask.is_error());
EXPECT(mask.error().string_literal().starts_with("invalid operation"));
EXPECT(mask.error().string_literal().starts_with("invalid operation"sv));
mask = Core::FilePermissionsMask::from_symbolic_notation("u+rz"sv);
EXPECT(mask.is_error());
EXPECT(mask.error().string_literal().starts_with("invalid symbolic permission"));
EXPECT(mask.error().string_literal().starts_with("invalid symbolic permission"sv));
mask = Core::FilePermissionsMask::from_symbolic_notation("u+rw;g+rw"sv);
EXPECT(mask.is_error());
EXPECT(mask.error().string_literal().starts_with("invalid symbolic permission"));
EXPECT(mask.error().string_literal().starts_with("invalid symbolic permission"sv));
}
TEST_CASE(file_permission_mask_parse)
@ -100,9 +100,9 @@ TEST_CASE(file_permission_mask_parse)
EXPECT_EQ(numeric_mask.value().clear_mask(), symbolic_mask.value().clear_mask());
EXPECT_EQ(numeric_mask.value().write_mask(), symbolic_mask.value().write_mask());
auto mask = Core::FilePermissionsMask::parse("888");
auto mask = Core::FilePermissionsMask::parse("888"sv);
EXPECT(mask.is_error());
mask = Core::FilePermissionsMask::parse("z+rw");
mask = Core::FilePermissionsMask::parse("z+rw"sv);
EXPECT(mask.is_error());
}

View file

@ -30,7 +30,7 @@ TEST_CASE(file_readline)
auto outputfile = outfile_or_error.release_value();
while (file->can_read_line()) {
outputfile->write(file->read_line());
outputfile->write("\n");
outputfile->write("\n"sv);
}
file->close();
outputfile->close();
@ -84,7 +84,7 @@ TEST_CASE(file_lines_range)
auto outputfile = outfile_or_error.release_value();
for (auto line : file->lines()) {
outputfile->write(line);
outputfile->write("\n");
outputfile->write("\n"sv);
}
file->close();
outputfile->close();

View file

@ -20,7 +20,7 @@
TEST_CASE(file_open)
{
auto maybe_file = Core::Stream::File::open("/tmp/file-open-test.txt", Core::Stream::OpenMode::Write);
auto maybe_file = Core::Stream::File::open("/tmp/file-open-test.txt"sv, Core::Stream::OpenMode::Write);
if (maybe_file.is_error()) {
warnln("Failed to open the file: {}", strerror(maybe_file.error().code()));
VERIFY_NOT_REACHED();
@ -40,7 +40,7 @@ TEST_CASE(file_open)
TEST_CASE(file_write_bytes)
{
auto maybe_file = Core::Stream::File::open("/tmp/file-write-bytes-test.txt", Core::Stream::OpenMode::Write);
auto maybe_file = Core::Stream::File::open("/tmp/file-write-bytes-test.txt"sv, Core::Stream::OpenMode::Write);
auto file = maybe_file.release_value();
constexpr auto some_words = "These are some words"sv;
@ -53,7 +53,7 @@ constexpr auto expected_buffer_contents = "<small>(Please consider transla
TEST_CASE(file_read_bytes)
{
auto maybe_file = Core::Stream::File::open("/usr/Tests/LibCore/long_lines.txt", Core::Stream::OpenMode::Read);
auto maybe_file = Core::Stream::File::open("/usr/Tests/LibCore/long_lines.txt"sv, Core::Stream::OpenMode::Read);
EXPECT(!maybe_file.is_error());
auto file = maybe_file.release_value();
@ -75,7 +75,7 @@ constexpr auto expected_seek_contents3 = "levels of advanc"sv;
TEST_CASE(file_seeking_around)
{
auto maybe_file = Core::Stream::File::open("/usr/Tests/LibCore/long_lines.txt", Core::Stream::OpenMode::Read);
auto maybe_file = Core::Stream::File::open("/usr/Tests/LibCore/long_lines.txt"sv, Core::Stream::OpenMode::Read);
EXPECT(!maybe_file.is_error());
auto file = maybe_file.release_value();
@ -137,7 +137,7 @@ TEST_CASE(file_adopt_invalid_fd)
TEST_CASE(file_truncate)
{
auto maybe_file = Core::Stream::File::open("/tmp/file-truncate-test.txt", Core::Stream::OpenMode::Write);
auto maybe_file = Core::Stream::File::open("/tmp/file-truncate-test.txt"sv, Core::Stream::OpenMode::Write);
auto file = maybe_file.release_value();
EXPECT(!file->truncate(999).is_error());
@ -417,7 +417,7 @@ TEST_CASE(local_socket_write)
TEST_CASE(buffered_long_file_read)
{
auto maybe_file = Core::Stream::File::open("/usr/Tests/LibCore/long_lines.txt", Core::Stream::OpenMode::Read);
auto maybe_file = Core::Stream::File::open("/usr/Tests/LibCore/long_lines.txt"sv, Core::Stream::OpenMode::Read);
EXPECT(!maybe_file.is_error());
auto maybe_buffered_file = Core::Stream::BufferedFile::create(maybe_file.release_value());
EXPECT(!maybe_buffered_file.is_error());
@ -439,7 +439,7 @@ TEST_CASE(buffered_long_file_read)
TEST_CASE(buffered_small_file_read)
{
auto maybe_file = Core::Stream::File::open("/usr/Tests/LibCore/small.txt", Core::Stream::OpenMode::Read);
auto maybe_file = Core::Stream::File::open("/usr/Tests/LibCore/small.txt"sv, Core::Stream::OpenMode::Read);
EXPECT(!maybe_file.is_error());
auto maybe_buffered_file = Core::Stream::BufferedFile::create(maybe_file.release_value());
EXPECT(!maybe_buffered_file.is_error());