Skip to content

Simplify looks_different() #247

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Jun 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions R/graphics.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,12 @@ local_plot_hooks <- function(f, frame = parent.frame()) {
# visual changes ---------------------------------------------------------

looks_different <- function(old_dl, new_dl) {
if (identical(old_dl, new_dl)) {
return(FALSE)
}

# If the new plot has fewer calls, it must be a visual change
if (length(new_dl) < length(old_dl)) {
return(TRUE)
}

# If the initial calls are different, it must be a visual change
if (!identical(old_dl[], new_dl[seq_along(old_dl)])) {
# If the old dl doesn't start with the new dl, then the plot must be different
if (!old_dl %is_prefix_of% new_dl) {
return(TRUE)
}

# If the last calls involve visual changes then it's a visual change
# If the last calls in the dl make visual changes then the plot is different
added_dl <- new_dl[-seq_along(old_dl)]
makes_visual_change(added_dl)
}
Expand Down