From 8c0674474e659472e062796f727e98be5909738d Mon Sep 17 00:00:00 2001 From: Benjamin Schwendinger <52290390+ben-schwen@users.noreply.github.com> Date: Sat, 20 Nov 2021 12:21:57 +0100 Subject: [PATCH] replace looped subsetVector with subsetDT --- R/data.table.R | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/R/data.table.R b/R/data.table.R index e020ea3e3..c4fdeb83f 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -1301,18 +1301,8 @@ replace_dot_alias = function(e) { # But rather than that complex logic here at R level to catch that and do a shallow copy for efficiency, just do the check inside CsubsetDT # to see if it passed 1:nrow(x) and then CsubsetDT should do the shallow copy safely and centrally. # That R level branch was taken out in PR #3213 - - # TO DO: use CsubsetDT twice here and then remove this entire R level branch - for (s in seq_along(icols)) { - target = icolsAns[s] - source = icols[s] - ans[[target]] = .Call(CsubsetVector,i[[source]],ii) # i.e. i[[source]][ii] - } - for (s in seq_along(xcols)) { - target = xcolsAns[s] - source = xcols[s] - ans[[target]] = .Call(CsubsetVector,x[[source]],irows) # i.e. x[[source]][irows], but guaranteed new memory even for singleton logicals from R 3.1.0 - } + ans[icolsAns] = .Call(CsubsetDT, i, ii, icols) + ans[xcolsAns] = .Call(CsubsetDT, x, irows, xcols) setattr(ans, "names", ansvars) if (haskey(x)) { keylen = which.first(!key(x) %chin% ansvars)-1L