diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp index b4def9ba17..5e49b1d4f7 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp @@ -370,7 +370,7 @@ static ErrorOr parse_prop_list(Core::InputBufferedFile& file, PropList& pr properties = { segments[1].trim_whitespace() }; for (auto& property : properties) { - auto& code_points = prop_list.ensure(sanitize_property ? sanitize_entry(property).trim_whitespace().view() : property.trim_whitespace()); + auto& code_points = prop_list.ensure(sanitize_property ? sanitize_entry(property).trim_whitespace() : ByteString { property.trim_whitespace() }); code_points.append(code_point_range); } } @@ -490,11 +490,11 @@ static ErrorOr parse_value_alias_list(Core::InputBufferedFile& file, Strin VERIFY((segments.size() == 3) || (segments.size() == 4)); auto value = primary_value_is_first ? segments[1].trim_whitespace() : segments[2].trim_whitespace(); auto alias = primary_value_is_first ? segments[2].trim_whitespace() : segments[1].trim_whitespace(); - append_alias(sanitize_alias ? sanitize_entry(alias).view() : alias, value); + append_alias(sanitize_alias ? sanitize_entry(alias) : ByteString { alias }, value); if (segments.size() == 4) { alias = segments[3].trim_whitespace(); - append_alias(sanitize_alias ? sanitize_entry(alias).view() : alias, value); + append_alias(sanitize_alias ? sanitize_entry(alias) : ByteString { alias }, value); } } diff --git a/Userland/Applications/Calendar/EventManager.cpp b/Userland/Applications/Calendar/EventManager.cpp index 81f0648365..bb12cada2b 100644 --- a/Userland/Applications/Calendar/EventManager.cpp +++ b/Userland/Applications/Calendar/EventManager.cpp @@ -42,8 +42,8 @@ ErrorOr EventManager::save(FileSystemAccessClient::File& file) set_filename(file.filename()); auto stream = file.release_stream(); - auto json = TRY(serialize_events()); - TRY(stream->write_some(json.to_byte_string().bytes())); + auto json = TRY(serialize_events()).to_byte_string(); + TRY(stream->write_some(json.bytes())); stream->close(); m_dirty = false; diff --git a/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp b/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp index 2a936a368d..8fd412c6e7 100644 --- a/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp @@ -87,8 +87,10 @@ ErrorOr BackgroundSettingsWidget::create_frame() m_copy_action = GUI::CommonActions::make_copy_action( [this](auto&) { auto wallpaper = m_monitor_widget->wallpaper(); - if (wallpaper.has_value()) - GUI::Clipboard::the().set_data(URL::create_with_file_scheme(wallpaper.value().to_byte_string()).to_byte_string().bytes(), "text/uri-list"); + if (wallpaper.has_value()) { + auto url = URL::create_with_file_scheme(wallpaper.value()).to_byte_string(); + GUI::Clipboard::the().set_data(url.bytes(), "text/uri-list"); + } }, this); m_context_menu->add_action(*m_copy_action); diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp index 4c85c59a41..190edfadc5 100644 --- a/Userland/Applications/FileManager/main.cpp +++ b/Userland/Applications/FileManager/main.cpp @@ -171,7 +171,7 @@ void do_copy(Vector const& selected_file_paths, FileOperation file_o auto url = URL::create_with_file_scheme(path); copy_text.appendff("{}\n", url); } - GUI::Clipboard::the().set_data(copy_text.to_byte_string().bytes(), "text/uri-list"); + GUI::Clipboard::the().set_data(copy_text.string_view().bytes(), "text/uri-list"); } void do_paste(ByteString const& target_directory, GUI::Window* window) diff --git a/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp b/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp index 964755e219..e4693e57d8 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp @@ -128,7 +128,8 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) else builder.appendff(" while evaluating builtin '{}'\n", frame.function_name); } else if (frame.source_range().filename().starts_with("cell "sv)) { - builder.appendff(" in cell '{}', at line {}, column {}\n", frame.source_range().filename().substring_view(5), frame.source_range().start.line, frame.source_range().start.column); + auto filename = frame.source_range().filename(); + builder.appendff(" in cell '{}', at line {}, column {}\n", filename.substring_view(5), frame.source_range().start.line, frame.source_range().start.column); } } return builder.to_byte_string(); diff --git a/Userland/Libraries/LibArchive/Tar.cpp b/Userland/Libraries/LibArchive/Tar.cpp index 457ab0c07d..a7c2105419 100644 --- a/Userland/Libraries/LibArchive/Tar.cpp +++ b/Userland/Libraries/LibArchive/Tar.cpp @@ -27,8 +27,11 @@ unsigned TarFileHeader::expected_checksum() const ErrorOr TarFileHeader::calculate_checksum() { memset(m_checksum, ' ', sizeof(m_checksum)); - bool copy_successful = TRY(String::formatted("{:06o}", expected_checksum())).bytes_as_string_view().copy_characters_to_buffer(m_checksum, sizeof(m_checksum)); + + auto octal = TRY(String::formatted("{:06o}", expected_checksum())); + bool copy_successful = octal.bytes_as_string_view().copy_characters_to_buffer(m_checksum, sizeof(m_checksum)); VERIFY(copy_successful); + return {}; } diff --git a/Userland/Libraries/LibArchive/Tar.h b/Userland/Libraries/LibArchive/Tar.h index 2186c6be2f..8b62ec21dc 100644 --- a/Userland/Libraries/LibArchive/Tar.h +++ b/Userland/Libraries/LibArchive/Tar.h @@ -84,7 +84,8 @@ static void set_field(char (&field)[N], TSource&& source) template static ErrorOr set_octal_field(char (&field)[N], TSource&& source) { - set_field(field, TRY(String::formatted("{:o}", forward(source))).bytes_as_string_view()); + auto octal = TRY(String::formatted("{:o}", forward(source))); + set_field(field, octal.bytes_as_string_view()); return {}; } diff --git a/Userland/Libraries/LibGfx/Font/FontDatabase.cpp b/Userland/Libraries/LibGfx/Font/FontDatabase.cpp index 7e0d39c365..d85b292144 100644 --- a/Userland/Libraries/LibGfx/Font/FontDatabase.cpp +++ b/Userland/Libraries/LibGfx/Font/FontDatabase.cpp @@ -118,7 +118,8 @@ void FontDatabase::load_all_fonts_from_uri(StringView uri) auto root = root_or_error.release_value(); root->for_each_descendant_file([this](Core::Resource const& resource) -> IterationDecision { - auto path = LexicalPath(resource.uri().bytes_as_string_view()); + auto uri = resource.uri(); + auto path = LexicalPath(uri.bytes_as_string_view()); if (path.has_extension(".font"sv)) { if (auto font_or_error = Gfx::BitmapFont::try_load_from_resource(resource); !font_or_error.is_error()) { auto font = font_or_error.release_value(); diff --git a/Userland/Libraries/LibHTTP/Job.cpp b/Userland/Libraries/LibHTTP/Job.cpp index ba8f4c497c..f157dd723a 100644 --- a/Userland/Libraries/LibHTTP/Job.cpp +++ b/Userland/Libraries/LibHTTP/Job.cpp @@ -313,8 +313,11 @@ void Job::on_socket_connected() // responds with nothing (content-length = 0 with normal encoding); if that's the case, // quit early as we won't be reading anything anyway. if (auto result = m_headers.get("Content-Length"sv).value_or(""sv).to_number(); result.has_value()) { - if (result.value() == 0 && !m_headers.get("Transfer-Encoding"sv).value_or(""sv).view().trim_whitespace().equals_ignoring_ascii_case("chunked"sv)) - return finish_up(); + if (result.value() == 0) { + auto transfer_encoding = m_headers.get("Transfer-Encoding"sv); + if (!transfer_encoding.has_value() || !transfer_encoding->view().trim_whitespace().equals_ignoring_ascii_case("chunked"sv)) + return finish_up(); + } } // There's also the possibility that the server responds with 204 (No Content), // and manages to set a Content-Length anyway, in such cases ignore Content-Length and quit early; diff --git a/Userland/Libraries/LibManual/Node.cpp b/Userland/Libraries/LibManual/Node.cpp index 20d8115599..c19220bff1 100644 --- a/Userland/Libraries/LibManual/Node.cpp +++ b/Userland/Libraries/LibManual/Node.cpp @@ -101,7 +101,7 @@ ErrorOr> Node::try_find_from_help_url(URL::URL const& child_node_found = false; auto children = TRY(current_node->children()); for (auto const& child : children) { - if (TRY(child->name()) == url.path_segment_at_index(i).view()) { + if (auto path = url.path_segment_at_index(i); TRY(child->name()) == path.view()) { child_node_found = true; current_node = child; break; diff --git a/Userland/Libraries/LibVT/TerminalWidget.cpp b/Userland/Libraries/LibVT/TerminalWidget.cpp index 861c86700c..9f9cfd7f23 100644 --- a/Userland/Libraries/LibVT/TerminalWidget.cpp +++ b/Userland/Libraries/LibVT/TerminalWidget.cpp @@ -1209,10 +1209,13 @@ void TerminalWidget::drop_event(GUI::DropEvent& event) if (!first) send_non_user_input(" "sv.bytes()); - if (url.scheme() == "file") - send_non_user_input(url.serialize_path().bytes()); - else - send_non_user_input(url.to_byte_string().bytes()); + if (url.scheme() == "file") { + auto path = url.serialize_path(); + send_non_user_input(path.bytes()); + } else { + auto url_string = url.to_byte_string(); + send_non_user_input(url_string.bytes()); + } first = false; } diff --git a/Userland/Libraries/LibVideo/Containers/Matroska/Reader.cpp b/Userland/Libraries/LibVideo/Containers/Matroska/Reader.cpp index 4a7de8357f..4fe66a5b11 100644 --- a/Userland/Libraries/LibVideo/Containers/Matroska/Reader.cpp +++ b/Userland/Libraries/LibVideo/Containers/Matroska/Reader.cpp @@ -468,11 +468,11 @@ static DecoderErrorOr parse_track_entry(Streamer& streamer) dbgln_if(MATROSKA_TRACE_DEBUG, "Read TrackType attribute: {}", to_underlying(track_entry.track_type())); break; case TRACK_LANGUAGE_ID: - track_entry.set_language(DECODER_TRY_ALLOC(FlyString::from_utf8(TRY_READ(streamer.read_string()).view()))); + track_entry.set_language(DECODER_TRY_ALLOC(String::from_byte_string(TRY_READ(streamer.read_string())))); dbgln_if(MATROSKA_TRACE_DEBUG, "Read Track's Language attribute: {}", track_entry.language()); break; case TRACK_CODEC_ID: - track_entry.set_codec_id(DECODER_TRY_ALLOC(FlyString::from_utf8(TRY_READ(streamer.read_string()).view()))); + track_entry.set_codec_id(DECODER_TRY_ALLOC(String::from_byte_string(TRY_READ(streamer.read_string())))); dbgln_if(MATROSKA_TRACE_DEBUG, "Read Track's CodecID attribute: {}", track_entry.codec_id()); break; case TRACK_TIMESTAMP_SCALE_ID: diff --git a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp index 9b8b209515..7f9c8d07d6 100644 --- a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp @@ -1337,7 +1337,8 @@ WebIDL::ExceptionOr> http_network_or_cache_fet // 11. If httpRequest’s referrer is a URL, then: if (http_request->referrer().has()) { // 1. Let referrerValue be httpRequest’s referrer, serialized and isomorphic encoded. - auto referrer_value = TRY_OR_THROW_OOM(vm, ByteBuffer::copy(http_request->referrer().get().serialize().bytes())); + auto referrer_string = http_request->referrer().get().serialize(); + auto referrer_value = TRY_OR_THROW_OOM(vm, ByteBuffer::copy(referrer_string.bytes())); // 2. Append (`Referer`, referrerValue) to httpRequest’s header list. auto header = Infrastructure::Header { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 9d6c7e60e1..f8ded54de2 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -189,7 +189,9 @@ FileFilter HTMLInputElement::parse_accept_attribute() const // If specified, the attribute must consist of a set of comma-separated tokens, each of which must be an ASCII // case-insensitive match for one of the following: - get_attribute_value(HTML::AttributeNames::accept).bytes_as_string_view().for_each_split_view(',', SplitBehavior::Nothing, [&](StringView value) { + auto accept = get_attribute_value(HTML::AttributeNames::accept); + + accept.bytes_as_string_view().for_each_split_view(',', SplitBehavior::Nothing, [&](StringView value) { // The string "audio/*" // Indicates that sound files are accepted. if (value.equals_ignoring_ascii_case("audio/*"sv)) diff --git a/Userland/Libraries/LibWeb/HTML/WindowProxy.cpp b/Userland/Libraries/LibWeb/HTML/WindowProxy.cpp index 46e2e9454d..7bcc9d954c 100644 --- a/Userland/Libraries/LibWeb/HTML/WindowProxy.cpp +++ b/Userland/Libraries/LibWeb/HTML/WindowProxy.cpp @@ -117,7 +117,9 @@ JS::ThrowCompletionOr> WindowProxy::internal_ge // 6. If property is undefined and P is in W's document-tree child navigable target name property set, then: auto navigable_property_set = m_window->document_tree_child_navigable_target_name_property_set(); - if (auto navigable = navigable_property_set.get(property_key.to_string().view()); navigable.has_value()) { + auto property_key_string = property_key.to_string(); + + if (auto navigable = navigable_property_set.get(property_key_string.view()); navigable.has_value()) { // 1. Let value be the active WindowProxy of the named object of W with the name P. auto value = navigable.value()->active_window_proxy(); diff --git a/Userland/Libraries/LibWebSocket/WebSocket.cpp b/Userland/Libraries/LibWebSocket/WebSocket.cpp index 5957efc18b..f34c5c1586 100644 --- a/Userland/Libraries/LibWebSocket/WebSocket.cpp +++ b/Userland/Libraries/LibWebSocket/WebSocket.cpp @@ -219,7 +219,7 @@ void WebSocket::send_client_handshake() builder.append("\r\n"sv); m_state = WebSocket::InternalState::WaitingForServerHandshake; - auto success = m_impl->send(builder.to_byte_string().bytes()); + auto success = m_impl->send(builder.string_view().bytes()); VERIFY(success); } diff --git a/Userland/Utilities/tail.cpp b/Userland/Utilities/tail.cpp index 743cd3edc1..4021e47b8d 100644 --- a/Userland/Utilities/tail.cpp +++ b/Userland/Utilities/tail.cpp @@ -148,7 +148,10 @@ ErrorOr serenity_main(Main::Arguments arguments) if (line_index >= wanted_line_count) line.append(ch); } - out("{}", line.to_byte_string().substring_view(1, line.length() - 1)); + + auto line_string = line.to_byte_string(); + out("{}", line_string.substring_view(1, line.length() - 1)); + continue; }