-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Simplify zeroGrob()
#6391
Conversation
| zeroGrob <- function() .zeroGrob | ||
|
|
||
| .zeroGrob <- NULL | ||
| on_load(.zeroGrob <- add_class(nullGrob(), "zeroGrob")) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
thomasp85
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Merge branch 'main' into discard_zerogrob # Conflicts: # NAMESPACE # R/grob-null.R # R/utilities.R # man/stat_connect.Rd # tests/testthat/test-facet-strips.R
This PR aim to fix #6390.
Briefly, instead of implementing a full
<zeroGrob>class, we piggyback on thegrid::nullGrob().Simplification is the goal of this PR.