Skip to content
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

Cache rlang version in .rlang_cli_compat()? #1609

Open
DavisVaughan opened this issue Mar 28, 2023 · 1 comment
Open

Cache rlang version in .rlang_cli_compat()? #1609

DavisVaughan opened this issue Mar 28, 2023 · 1 comment

Comments

@DavisVaughan
Copy link
Member

I've wondered why lifecycle signaling is so slow, and it looks like there are two main reasons:

Screen Shot 2023-03-28 at 2 55 23 PM

This seems like a reasonable thing to cache, right?

@DavisVaughan
Copy link
Member Author

Since this is in a standalone file, we can probably mimic .rlang_cli_has_cli()

rlang/R/standalone-cli.R

Lines 405 to 419 in c55f602

.rlang_cli_has_cli <- local({
cache <- new.env()
function(version = "3.0.0") {
out <- cache[[version]]
if (is.null(out)) {
out <- cache[[version]] <<-
requireNamespace("cli", quietly = TRUE) &&
utils::packageVersion("cli") >= version
}
out
}
})

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

No branches or pull requests

1 participant