mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
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.
This commit is contained in:
parent
37e29a630b
commit
504d622864
Notes:
sideshowbarker
2024-07-18 19:01:30 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/504d6228645
1 changed files with 3 additions and 8 deletions
|
@ -140,18 +140,13 @@ void TextNode::split_into_lines_by_rules(InlineFormattingContext& context, Layou
|
|||
m_text_for_rendering = dom_node().data();
|
||||
}
|
||||
|
||||
Vector<Chunk, 128> 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)
|
||||
|
|
Loading…
Reference in a new issue