Skip to content

Commit 40ad2e6

Browse files
committed
Drop direct use of NAMED
Since data.table now depends on R >= 3.3, the backports are no longer needed. Moreover, MAYBE_SHARED is currently a function, while MAYBE_REFERENCED expands to !NO_REFERENCES (which is a function). In debugging output, show MAYBE_REFERENCED (NAMED > 0) instead of NAMED.
1 parent 6f1d22f commit 40ad2e6

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

src/assign.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,12 +549,12 @@ SEXP assign(SEXP dt, SEXP rows, SEXP cols, SEXP newcolnames, SEXP values)
549549
(TYPEOF(values)!=VECSXP && i>0) // assigning the same values to a second column. Have to ensure a copy #2540
550550
) {
551551
if (verbose) {
552-
Rprintf(_("RHS for item %d has been duplicated because NAMED==%d MAYBE_SHARED==%d, but then is being plonked. length(values)==%d; length(cols)==%d)\n"),
553-
i+1, NAMED(thisvalue), MAYBE_SHARED(thisvalue), length(values), length(cols));
552+
Rprintf(_("RHS for item %d has been duplicated because MAYBE_REFERENCED==%d MAYBE_SHARED==%d, but then is being plonked. length(values)==%d; length(cols)==%d)\n"),
553+
i+1, MAYBE_REFERENCED(thisvalue), MAYBE_SHARED(thisvalue), length(values), length(cols));
554554
}
555555
thisvalue = copyAsPlain(thisvalue); // PROTECT not needed as assigned as element to protected list below.
556556
} else {
557-
if (verbose) Rprintf(_("Direct plonk of unnamed RHS, no copy. NAMED==%d, MAYBE_SHARED==%d\n"), NAMED(thisvalue), MAYBE_SHARED(thisvalue)); // e.g. DT[,a:=as.character(a)] as tested by 754.5
557+
if (verbose) Rprintf(_("Direct plonk of unnamed RHS, no copy. MAYBE_REFERENCED==%d, MAYBE_SHARED==%d\n"), MAYBE_REFERENCED(thisvalue), MAYBE_SHARED(thisvalue)); // e.g. DT[,a:=as.character(a)] as tested by 754.5
558558
}
559559
SET_VECTOR_ELT(dt, coln, thisvalue); // plonk new column in as it's already the correct length
560560
setAttrib(thisvalue, R_NamesSymbol, R_NilValue); // clear names such as DT[,a:=mapvector[a]]

src/data.table.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,6 @@
6060
// for use with CPLXSXP, no macro provided by R internals
6161
#define ISNAN_COMPLEX(x) (ISNAN((x).r) || ISNAN((x).i)) // TRUE if either real or imaginary component is NA or NaN
6262

63-
// Backport macros added to R in 2017 so we don't need to update dependency from R 3.0.0
64-
#ifndef MAYBE_SHARED
65-
# define MAYBE_SHARED(x) (NAMED(x) > 1)
66-
#endif
67-
#ifndef MAYBE_REFERENCED
68-
# define MAYBE_REFERENCED(x) ( NAMED(x) > 0 )
69-
#endif
70-
7163
// If we find a non-ASCII, non-NA, non-UTF8 encoding, we try to convert it to UTF8. That is, marked non-ascii/non-UTF8 encodings will
7264
// always be checked in UTF8 locale. This seems to be the best fix Arun could think of to put the encoding issues to rest.
7365
// Since the if-statement will fail with the first condition check in "normal" ASCII cases, there shouldn't be huge penalty issues in

0 commit comments

Comments
 (0)