Skip to content
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
@@ -1,5 +1,7 @@
# rlang (development version)

* `list2()` is now a little faster (#1837).

* New `%&&%` operator that returns RHS when LHS is non-NULL (#1774, @snystrom).

* C code no longer calls `memcpy()` and `memset()` on 0-length R object memory
Expand Down
11 changes: 1 addition & 10 deletions R/dots.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,7 @@ NULL
#'
#' @export
list2 <- function(...) {
.Call(
ffi_dots_list,
frame_env = environment(),
named = NULL,
ignore_empty = "trailing",
preserve_empty = FALSE,
unquote_names = TRUE,
homonyms = "keep",
check_assign = FALSE
)
.External2(ffi_list2)
}
#' @rdname list2
#' @usage NULL
Expand Down
3 changes: 3 additions & 0 deletions src/internal/cnd-handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
r_obj* ffi_try_fetch(r_obj* try_fetch_args) {
r_obj* env = r_node_cadr(try_fetch_args);

// TODO: `rlang_env_dots_list()` will always clone `handlers`
// on the way out, and we could probably avoid that by switching
// to or creating another variant that doesn't clone.
r_obj* handlers = KEEP(rlang_env_dots_list(env));
r_env_poke(env, rlang_syms.handlers, handlers);

Expand Down
20 changes: 20 additions & 0 deletions src/internal/dots.c
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,8 @@ r_obj* ffi_dots_values(r_obj* args) {
return out;
}

// Deprecated
// Used by vctrs <= 0.6.5, so can't easily remove.
// [[ export() ]]
r_obj* rlang_env_dots_values(r_obj* env) {
return dots_values_impl(env,
Expand All @@ -969,6 +971,8 @@ r_obj* rlang_env_dots_values(r_obj* env) {
false);
}

// Deprecated
// Used by vctrs <= 0.6.5, so can't easily remove.
// [[ export() ]]
r_obj* rlang_env_dots_list(r_obj* env) {
r_obj* out = KEEP(dots_values_impl(env,
Expand All @@ -979,12 +983,28 @@ r_obj* rlang_env_dots_list(r_obj* env) {
rlang_objs_keep,
r_false,
true));
// Deprecated due to this clone being unnecessary.
// `rlang_env_dots_list()` has the exact same defaults as `list2()`, and
// `list2()` avoids the clone, so in vctrs we now just use that instead.
out = r_vec_clone_shared(out);

FREE(1);
return out;
}

// Specialization for maximum performance via `External2()`, which is a little
// faster than `.Call()` and gives us `frame_env` for free rather than needing
// an R level `environment()` call
r_obj* ffi_list2(r_obj* call, r_obj* op, r_obj* args, r_obj* frame_env) {
return dots_values_impl(frame_env,
r_null,
rlang_objs_trailing,
r_false,
r_true,
rlang_objs_keep,
r_false,
true);
}
r_obj* ffi_dots_list(r_obj* frame_env,
r_obj* named,
r_obj* ignore_empty,
Expand Down
7 changes: 5 additions & 2 deletions src/internal/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ static const R_ExternalMethodDef externals[] = {
{"ffi_exec", (DL_FUNC) &ffi_exec, 2},
{"ffi_tilde_eval", (DL_FUNC) &ffi_tilde_eval, 3},
{"ffi_try_fetch", (DL_FUNC) &ffi_try_fetch, 1},
{"ffi_list2", (DL_FUNC) &ffi_list2, 0},
{NULL, NULL, 0}
};

Expand Down Expand Up @@ -387,8 +388,6 @@ void R_init_rlang(DllInfo* dll) {
R_RegisterCCallable("rlang", "rlang_xxh3_64bits", (DL_FUNC) &XXH3_64bits);

// Maturing
R_RegisterCCallable("rlang", "rlang_env_dots_list", (DL_FUNC) &rlang_env_dots_list);
R_RegisterCCallable("rlang", "rlang_env_dots_values", (DL_FUNC) &rlang_env_dots_values);
R_RegisterCCallable("rlang", "rlang_is_splice_box", (DL_FUNC) &is_splice_box);
R_RegisterCCallable("rlang", "rlang_obj_encode_utf8", (DL_FUNC) &obj_encode_utf8);
R_RegisterCCallable("rlang", "rlang_str_as_symbol", (DL_FUNC) &r_str_as_symbol);
Expand All @@ -399,6 +398,10 @@ void R_init_rlang(DllInfo* dll) {
// Experimental
R_RegisterCCallable("rlang", "rlang_squash_if", (DL_FUNC) &r_squash_if);

// Deprecated
R_RegisterCCallable("rlang", "rlang_env_dots_list", (DL_FUNC) &rlang_env_dots_list);
R_RegisterCCallable("rlang", "rlang_env_dots_values", (DL_FUNC) &rlang_env_dots_values);
Comment on lines +401 to +403
Copy link
Member Author

Choose a reason for hiding this comment

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

I deprecated both of these because vctrs is the only one using them, and now we don't use either


// Compatibility
R_RegisterCCallable("rlang", "rlang_as_data_mask", (DL_FUNC) &ffi_as_data_mask_compat);
R_RegisterCCallable("rlang", "rlang_new_data_mask", (DL_FUNC) &ffi_new_data_mask_compat);
Expand Down