Skip to content

Simplify zeroGrob() #6391

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

teunbrand
Copy link
Collaborator

This PR aim to fix #6390.

Briefly, instead of implementing a full <zeroGrob> class, we piggyback on the grid::nullGrob().
Simplification is the goal of this PR.

zeroGrob <- function() .zeroGrob

.zeroGrob <- NULL
on_load(.zeroGrob <- add_class(nullGrob(), "zeroGrob"))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The zeroGrob class is appended here, because inherits(x, "zeroGrob") is sometimes used instead of is.zero(). I expect the situation to be the same in extension packages.

#'
#' @keywords internal
#' @export
zeroGrob <- function() .zeroGrob
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've not removed this function altogether because there is some optimisation value in only constructing the .zeroGrob object once per session instead of all over the place. Moreover, I expect it might be prevalent in extensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace zeroGrob() with grid::nullGrob()
1 participant