Skip to content

Commit

Permalink
replace loop with walk for speed
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzwalthert committed Jan 11, 2021
1 parent b3e32bb commit 3061e30
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ importFrom(purrr,map_lgl)
importFrom(purrr,partial)
importFrom(purrr,pmap)
importFrom(purrr,pwalk)
importFrom(purrr,walk)
importFrom(purrr,when)
importFrom(rlang,abort)
importFrom(rlang,is_empty)
Expand Down
5 changes: 3 additions & 2 deletions R/transform-files.R
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,14 @@ parse_transform_serialize_r <- function(text,
#' that trigger are required to be absent to trigger a removal.
#' @param scope The low-level scope, e.g. 'token'.
#' @param code tokenized code for which we check if `token` is in them.
#' @importFrom purrr walk
transformers_subset_impl <- function(transformers, token, scope, code) {
transformer_names <- names(token)
for (i in seq_along(token)) {
walk(seq_along(token), function(i) {
if (!any(token[[i]] %in% code)) {
transformers[[scope]][[transformer_names[i]]] <- NULL
}
}
})
transformers
}

Expand Down

0 comments on commit 3061e30

Please sign in to comment.