Skip to content

Commit

Permalink
try to speed up counters
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Dec 23, 2024
1 parent e971d52 commit 4bc8bc9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions R/class_counter.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ counter_filter_exists <- function(counter, names) {
}

counter_set_name <- function(counter, name) {
is_new <- !counter_exists_name(counter, name)
assign(x = name, value = TRUE, envir = counter$envir)
counter$count <- counter$count + is_new
envir <- .subset2(counter, "envir")
if (is.null(.subset2(envir, name))) {
envir[[name]] <- TRUE
counter$count <- .subset2(counter, "count") + 1L
}
}

counter_set_names <- function(counter, names) {
Expand Down

0 comments on commit 4bc8bc9

Please sign in to comment.