diff --git a/NEWS.md b/NEWS.md index 6f3048d61..f00b168ee 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/R/standalone-cli.R b/R/standalone-cli.R index fc668fec4..a284967bb 100644 --- a/R/standalone-cli.R +++ b/R/standalone-cli.R @@ -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 # --- # @@ -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 @@ -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),