Skip to content

Commit

Permalink
Reduce work when adding split points
Browse files Browse the repository at this point in the history
No need to iterate over all split points when there is no split point to
add in the first place
  • Loading branch information
lampsitter committed Sep 1, 2023
1 parent 2821910 commit 0757b0f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ impl ImageHandleCache {
}
}

impl ImageHandleCache {}

/// A cache used for storing content such as images.
pub struct CommonMarkCache {
// Everything stored here must take into account that the cache is for multiple
Expand Down Expand Up @@ -519,7 +517,7 @@ impl CommonMarkViewerInternal {
should_add_split_point = true;
}

if populate_split_points {
if populate_split_points && should_add_split_point {
let scroll_cache = cache.scroll(&self.source_id);
let end_position = ui.next_widget_position();

Expand All @@ -528,7 +526,7 @@ impl CommonMarkViewerInternal {
.iter()
.any(|(i, _, _)| *i == index);

if should_add_split_point && !split_point_exists {
if !split_point_exists {
scroll_cache
.split_points
.push((index, start_position, end_position));
Expand Down

0 comments on commit 0757b0f

Please sign in to comment.