From 504d62286452b5537b723ee3baf3f85867fcd690 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 27 Apr 2021 19:06:35 +0200 Subject: [PATCH] LibWeb: Remove unnecessary temporary Vector in text layout Now that we have Layout::TextNode::ChunkIterator, we don't need to accumulate all the chunks in a vector before dividing them into lines. --- Userland/Libraries/LibWeb/Layout/TextNode.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Userland/Libraries/LibWeb/Layout/TextNode.cpp b/Userland/Libraries/LibWeb/Layout/TextNode.cpp index c3b388a420..adab30210a 100644 --- a/Userland/Libraries/LibWeb/Layout/TextNode.cpp +++ b/Userland/Libraries/LibWeb/Layout/TextNode.cpp @@ -140,18 +140,13 @@ void TextNode::split_into_lines_by_rules(InlineFormattingContext& context, Layou m_text_for_rendering = dom_node().data(); } - Vector chunks; ChunkIterator iterator(m_text_for_rendering, layout_mode, do_wrap_lines, do_wrap_breaks); for (;;) { - auto chunk = iterator.next(); - if (!chunk.has_value()) + auto chunk_opt = iterator.next(); + if (!chunk_opt.has_value()) break; - chunks.append(chunk.release_value()); - } - - for (size_t i = 0; i < chunks.size(); ++i) { - auto& chunk = chunks[i]; + auto& chunk = chunk_opt.value(); // Collapse entire fragment into non-existence if previous fragment on line ended in whitespace. if (do_collapse && line_boxes.last().is_empty_or_ends_in_whitespace() && chunk.is_all_whitespace)