Skip to content

Commit

Permalink
Directly call .shallow to keep selfrefok() in other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico committed Sep 29, 2024
1 parent ae0fc5f commit e22e768
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -2923,17 +2923,17 @@ setDT = function(x, keep.rownames=FALSE, key=NULL, check.names=FALSE) {
}
}

# setalloccol results in a shallow copy. Must be performed before class setting,
# to have the class apply only to the new copy. #4784
setalloccol(x)
# setalloccol results in a shallow copy. Must be performed before class setting not to affect other copies of x (#4784)
x = .shallow(x)

rn = if (!identical(keep.rownames, FALSE)) rownames(x) else NULL
setattr(x, "row.names", .set_row_names(nrow(x)))
if (check.names) setattr(x, "names", make.names(names(x), unique=TRUE))

# fix for #1078 and #1128, see .resetclass() for explanation.
setattr(x, "class", .resetclass(x, 'data.frame'))

setalloccol(x)

Check warning on line 2936 in R/data.table.R

View workflow job for this annotation

GitHub Actions / lint-r

file=R/data.table.R,line=2936,col=1,[trailing_whitespace_linter] Remove trailing whitespace.
if (!is.null(rn)) {
nm = c(if (is.character(keep.rownames)) keep.rownames[1L] else "rn", names(x))
x[, (nm[1L]) := rn]
Expand Down

0 comments on commit e22e768

Please sign in to comment.