1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 10:17:35 +00:00

LibCore+Everywhere: Make Core::Stream read_line() return StringView

Similar reasoning to making Core::Stream::read() return Bytes, except
that every user of read_line() creates a StringView from the result, so
let's just return one right away.
This commit is contained in:
Sam Atkins 2022-04-15 14:52:33 +01:00 committed by Tim Flynn
parent c4134e9794
commit d564cf1e89
9 changed files with 40 additions and 54 deletions

View file

@ -72,13 +72,13 @@ FileOperationProgressWidget::FileOperationProgressWidget(FileOperation operation
m_notifier = Core::Notifier::construct(helper_pipe_fd, Core::Notifier::Read);
m_notifier->on_ready_to_read = [this] {
auto line_buffer = ByteBuffer::create_zeroed(1 * KiB).release_value_but_fixme_should_propagate_errors();
auto line_length_or_error = m_helper_pipe->read_line(line_buffer.bytes());
if (line_length_or_error.is_error() || line_length_or_error.value() == 0) {
auto line_or_error = m_helper_pipe->read_line(line_buffer.bytes());
if (line_or_error.is_error() || line_or_error.value().is_empty()) {
did_error("Read from pipe returned null."sv);
return;
}
StringView line { line_buffer.bytes().data(), line_length_or_error.value() };
auto line = line_or_error.release_value();
auto parts = line.split_view(' ');
VERIFY(!parts.is_empty());