Skip to content

Commit 8b5027e

Browse files
Ditch mergelist(copy=) for setmergelist
1 parent 58a2c8e commit 8b5027e

File tree

4 files changed

+98
-86
lines changed

4 files changed

+98
-86
lines changed

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export(nafill)
5959
export(setnafill)
6060
export(.Last.updated)
6161
export(fcoalesce)
62-
export(mergelist)
62+
export(mergelist, setmergelist)
6363
export(cbindlist, setcbindlist)
6464
export(substitute2)
6565
#export(DT) # mtcars |> DT(i,j,by) #4872 #5472

R/mergelist.R

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ mergepair = function(lhs, rhs, on, how, mult, lhs.cols=names(lhs), rhs.cols=name
257257
setDT(out)
258258
}
259259

260-
mergelist = function(l, on, cols, how=c("left", "inner", "full", "right", "semi", "anti", "cross"), mult, copy=TRUE, join.many=getOption("datatable.join.many")) {
260+
mergelist_impl_ = function(l, on, cols, how, mult, copy) {
261261
verbose = getOption("datatable.verbose")
262262
if (verbose)
263263
p = proc.time()[[3L]]
@@ -294,8 +294,6 @@ mergelist = function(l, on, cols, how=c("left", "inner", "full", "right", "semi"
294294
if (length(mult) != n - 1L || !all(vapply_1b(mult, function(x) is.null(x) || (is.character(x) && length(x) == 1L && !anyNA(x) && x %chin% c("error", "all", "first", "last")))))
295295
stopf("'mult' must be one of [error, all, first, last] or NULL, or a list of such whose length must be length(l)-1L")
296296

297-
if (missing(how) || is.null(how))
298-
how = match.arg(how)
299297
if (!is.list(how))
300298
how = rep(list(how), n-1L)
301299
if (length(how)!=n-1L || !all(vapply_1b(how, function(x) is.character(x) && length(x)==1L && !anyNA(x) && x %chin% c("left", "inner", "full", "right", "semi", "anti", "cross"))))
@@ -348,6 +346,17 @@ mergelist = function(l, on, cols, how=c("left", "inner", "full", "right", "semi"
348346
out
349347
}
350348

349+
mergelist = function(l, on, cols, how=c("left", "inner", "full", "right", "semi", "anti", "cross"), mult, join.many=getOption("datatable.join.many")) {
350+
if (missing(how) || is.null(how))
351+
how = match.arg(how)
352+
mergelist_impl_(l, on, cols, how, mult, join.many, copy=TRUE)
353+
}
354+
setmergelist = function(l, on, cols, how=c("left", "inner", "full", "right", "semi", "anti", "cross"), mult, join.many=getOption("datatable.join.many")) {
355+
if (missing(how) || is.null(how))
356+
how = match.arg(how)
357+
mergelist_impl_(l, on, cols, how, mult, join.many, copy=FALSE)
358+
}
359+
351360
# Previously, we had a custom C implementation here, which is ~2x faster,
352361
# but this is fast enough we don't bother maintaining a new routine.
353362
# Hopefully in the future rep() can recognize the ALTREP and use that, too.

0 commit comments

Comments
 (0)