Skip to content

Commit

Permalink
optimize lookup loops
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Jan 10, 2025
1 parent 6013213 commit 19e487c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions R/class_lookup.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,20 @@ lookup_count <- function(lookup) {
}

lookup_set <- function(lookup, names, object) {
for (name in names) {
lookup[[name]] <- object
index <- 1L
n <- length(names)
while (index <= n) {
lookup[[.subset(names, index)]] <- object
index <- index + 1L
}
}

lookup_unset <- function(lookup, names) {
for (name in names) {
lookup[[name]] <- NULL
index <- 1L
n <- length(names)
while (index <= n) {
lookup[[.subset(names, index)]] <- NULL
index <- index + 1L
}
}

Expand Down

0 comments on commit 19e487c

Please sign in to comment.