Skip to content

Commit

Permalink
replace looped subsetVector with subsetDT (#5264)
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-schwen authored Dec 3, 2021
1 parent 198f452 commit 2ef323c
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions R/data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -1303,18 +1303,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
Expand Down

0 comments on commit 2ef323c

Please sign in to comment.