Skip to content

Commit 653d798

Browse files
Use mapply()
1 parent ce726c2 commit 653d798

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

R/tables.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ tables = function(mb=type_size, order.col="NAME", width=80L,
2525
mb_name = as.character(substitute(mb))
2626
if (isTRUE(mb)) { mb=type_size; mb_name="type_size" }
2727
names = ls(envir=env, all.names=TRUE) # include "hidden" objects (starting with .)
28-
obj = mget(names, envir=env) # doesn't copy; mget is ok with ... unlike get, #5197
28+
objs = mget(names, envir=env) # doesn't copy; mget is ok with ... unlike get, #5197
2929
found_items = list()
3030
if (recursive) {
31-
agenda = lapply(seq_along(obj), function(i) list(obj=obj[[i]], name=names[i]))
31+
agenda = mapply(function(obj, name) list(obj=obj, name=name), objs, names, SIMPLIFY=FALSE, USE.NAMES=FALSE)
3232
visited_env = new.env(hash=TRUE)
3333

3434
while (length(agenda)) {
@@ -60,7 +60,7 @@ tables = function(mb=type_size, order.col="NAME", width=80L,
6060
}
6161
}
6262
} else {
63-
w = which(vapply_1b(obj, is.data.table))
63+
w = which(vapply_1b(objs, is.data.table))
6464
if (length(w)) {
6565
found_items = lapply(w, function(i) list(name=names[i], obj=obj[[i]]))
6666
}

0 commit comments

Comments
 (0)