Skip to content

Conversation

DavisVaughan
Copy link
Member

Another ~30% faster by avoiding .rlang_cli_format_fallback() and getting to specify cli(use_cli_format = FALSE) explicitly

cross::bench_branches(\() {
  library(lifecycle)
  
  # trigger the 8 hour warning once
  deprecate_soft("1.1.0", I("my thing"), details = "for this reason")

  bench::mark(
    deprecate_soft("1.1.0", I("my thing"), details = "for this reason")
  )
})
#> # A tibble: 2 × 7
#>   branch                   expression                                 min median `itr/sec` mem_alloc `gc/sec`
#>   <chr>                    <bch:expr>                              <bch:> <bch:>     <dbl> <bch:byt>    <dbl>
#> 1 feature/manual-condition "deprecate_soft(\"1.1.0\", I(\"my thin… 48.5µs 51.1µs    18777.    8.56KB     160.
#> 2 main                     "deprecate_soft(\"1.1.0\", I(\"my thin… 73.3µs 75.6µs    12899.    8.56KB     169.
Screenshot 2025-10-03 at 10 59 09 AM Screenshot 2025-10-03 at 10 59 16 AM

"lifecycle_stage",
# Much faster than calling `rlang::signal()` directly.
# `message` is already formatted so we don't need to worry about cli.
cnd_signal(cnd(
Copy link
Member

Choose a reason for hiding this comment

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

Can you make the condition object directly with structure()? (like simpleCondition())

Copy link
Member

Choose a reason for hiding this comment

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

Hmmm, and use signalCondition()?

Copy link
Member Author

Choose a reason for hiding this comment

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

See #195 for the fully lazy way

@DavisVaughan DavisVaughan merged commit 1893282 into main Oct 3, 2025
14 checks passed
@DavisVaughan DavisVaughan deleted the feature/manual-condition branch October 3, 2025 17:14
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.

2 participants