Skip to content

Commit

Permalink
refactor: use std::mem::take instead of cloning and clearing `seg_b…
Browse files Browse the repository at this point in the history
…uff` in `ReflowSequence`
  • Loading branch information
gvozdvmozgu authored and benfdking committed Nov 27, 2024
1 parent 4569077 commit c58e75b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions crates/lib/src/utils/reflow/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ impl<'a> ReflowSequence<'a> {
} else if !elem_buff.is_empty() || !seg_buff.is_empty() {
// There are elements. The last will have been a block.
// Add a point before we add the block. NOTE: It may be empty.
elem_buff.push(ReflowElement::Point(ReflowPoint::new(seg_buff.clone())));
let seg_buff = take(&mut seg_buff);
elem_buff.push(ReflowElement::Point(ReflowPoint::new(seg_buff)));
}

// Add the block, with config info.
Expand All @@ -119,9 +120,6 @@ impl<'a> ReflowSequence<'a> {
reflow_config,
depth_info,
)));

// Empty the buffer
seg_buff.clear();
}

if !seg_buff.is_empty() {
Expand Down

0 comments on commit c58e75b

Please sign in to comment.