Skip to content

Commit

Permalink
optimize a filter
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Jan 7, 2025
1 parent 1b1a16f commit 7dfe8fd
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions R/class_meta.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,16 @@ meta_class <- R6::R6Class(
restrict_records = function(pipeline) {
names_envir <- names(pipeline$imports)
names_records <- self$list_records()
names_children <- fltr(
names_records,
~self$database$get_row(.x)$type == "branch"
)
index <- 1L
n <- length(names_records)
get_row <- database$get_row
is_branch <- vector(mode = "logical", length = n)
while (index <= n) {
name <- .subset(names_records, index)
is_branch[index] <- .subset2(get_row(name), "type") == "branch"
index <- index + 1L
}
names_children <- names_records[is_branch]
names_targets <- pipeline_get_names(pipeline)
names_parents <- intersect(names_records, names_targets)
names_current <- c(names_envir, names_targets, names_children)
Expand Down

0 comments on commit 7dfe8fd

Please sign in to comment.