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

speed up package version check in .rlang_cli_compat() #1657

Merged
merged 1 commit into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

* `expr_label()` now has back-compatility with respect to changes made by R version 4.4 and `is.atomic(NULL)` (#1655)

* Performance improvement in `.rlang_cli_compat()` (#1657).

# rlang 1.1.1

* `englue()` now allows omitting `{{`. This is to make it easier to
Expand Down
14 changes: 11 additions & 3 deletions R/standalone-cli.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ---
# repo: r-lib/rlang
# file: standalone-cli.R
# last-updated: 2022-09-23
# last-updated: 2023-10-06
# license: https://unlicense.org
# ---
#
Expand All @@ -11,6 +11,10 @@
#
# ## Changelog
#
# 2023-10-06:
#
# * Speedup in `.rlang_cli_compat()`.
#
# 2022-09-23:
#
# * `format_` functions now use `cli::format_inline()` instead of
Expand Down Expand Up @@ -451,8 +455,12 @@ cli_escape <- function(x) {
is_interactive = return(rlang::is_interactive)
)

# Make sure rlang knows about "x" and "i" bullets
if (utils::packageVersion("rlang") >= "0.4.2") {
ns <- asNamespace("rlang")

# Make sure rlang knows about "x" and "i" bullets.
# Pull from namespace rather than via `utils::packageVersion()`
# to avoid slowdown (#1657)
if (ns[[".__NAMESPACE__."]][["spec"]][["version"]] >= "0.4.2") {
switch(
fn,
abort = return(rlang::abort),
Expand Down
Loading