Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mschubert committed Aug 2, 2024
1 parent 69a55de commit 9adf7c1
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions R/foreach.r
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ cmq_foreach = function(obj, expr, envir, data) {

# wrap whatever we call in a function for use with Q(...)
fun = function(...) NULL
formals(fun) = c(stats::setNames(replicate(ncol(args_df), substitute()),
obj$argnames),
formals(fun))
add = stats::setNames(replicate(ncol(args_df), substitute()), obj$argnames)
formals(fun) = c(add, formals(fun))
body(fun) = expr

# scan 'expr' for exports, eval and add objects ref'd in '.export'
Expand All @@ -54,9 +53,8 @@ cmq_foreach = function(obj, expr, envir, data) {
data$export = utils::modifyList(as.list(data$export), globs, keep.null=TRUE)

# make sure packages are loaded on the dopar target
if (length(obj$packages) > 0) {
if (length(obj$packages) > 0)
data$pkgs = unique(c(data$pkgs, obj$packages))
}

result = do.call(Q_rows, c(list(df=args_df, fun=fun), data))

Expand Down

0 comments on commit 9adf7c1

Please sign in to comment.