Skip to content

Commit

Permalink
try to speed up counter_count_exists()
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Jan 10, 2025
1 parent ed62f64 commit d351ddf
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions R/class_counter.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ counter_filter_exists <- function(counter, names) {
counter_count_exists <- function(counter, names) {
envir <- .subset2(counter, "envir")
out <- 0L
for (name in names) {
if (!is.null(.subset2(envir, name))) {
out <- out + 1L
}
index <- 1L
n <- length(names)
while (index <= n) {
out <- out + !is.null(.subset2(envir, .subset(names, index)))
index <- index + 1L
}
out
}
Expand Down

0 comments on commit d351ddf

Please sign in to comment.