Skip to contents

charr_backend() selects the implementation used by charr's public string functions. Dispatch happens once, in R, when a public operation starts. Nested calls stay within the selected backend.

Usage

charr_backend(value = NULL)

Arguments

value

NULL to query the current backend, or one of "reference", "base", or "altrep" to select a backend.

Value

The current backend when querying. When setting, the previous backend is returned invisibly.

Details

The available backends are:

  • "reference": the original stringr implementation, which calls stringi.

  • "base": charr's optimized backend returning ordinary R character vectors.

  • "altrep": charr's optimized charport backend returning ALTREP character vectors where appropriate. This is the default.

The selection is stored in the global charr_backend option. Changing the option affects later public calls; it does not change an operation already in progress.

Examples

old <- charr_backend("base")
charr_backend()
#> [1] "base"
charr_backend(old)