Skip to content

Commit 23c05c0

Browse files
authored
Replace the use of SET_OBJECT (#7450)
Instead of manually transplanting ATTRIB and then restoring the object bits, use SHALLOW_DUPLICATE_ATTRIB, which takes care of the bits.
1 parent e3ec68a commit 23c05c0

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

src/dogroups.c

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -510,21 +510,6 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX
510510
return(ans);
511511
}
512512

513-
SEXP keepattr(SEXP to, SEXP from)
514-
{
515-
// Same as R_copyDFattr in src/main/attrib.c, but that seems not exposed in R's api
516-
// Only difference is that we reverse from and to in the prototype, for easier calling above
517-
SET_ATTRIB(to, ATTRIB(from));
518-
if (isS4(from)) {
519-
to = PROTECT(asS4(to, TRUE, 1));
520-
SET_OBJECT(to, isObject(from));
521-
UNPROTECT(1);
522-
} else {
523-
SET_OBJECT(to, isObject(from));
524-
}
525-
return to;
526-
}
527-
528513
SEXP growVector(SEXP x, const R_len_t newlen)
529514
{
530515
// Similar to EnlargeVector in src/main/subassign.c, with the following changes :
@@ -537,7 +522,7 @@ SEXP growVector(SEXP x, const R_len_t newlen)
537522
PROTECT(newx = allocVector(TYPEOF(x), newlen)); // TO DO: R_realloc(?) here?
538523
if (newlen < len) len=newlen; // i.e. shrink
539524
if (!len) { // cannot memcpy invalid pointer, #6819
540-
keepattr(newx, x);
525+
SHALLOW_DUPLICATE_ATTRIB(newx, x);
541526
UNPROTECT(1);
542527
return newx;
543528
}
@@ -562,7 +547,7 @@ SEXP growVector(SEXP x, const R_len_t newlen)
562547
}
563548
// if (verbose) Rprintf(_("Growing vector from %d to %d items of type '%s'\n"), len, newlen, type2char(TYPEOF(x)));
564549
// Would print for every column if here. Now just up in dogroups (one msg for each table grow).
565-
keepattr(newx,x);
550+
SHALLOW_DUPLICATE_ATTRIB(newx, x);
566551
UNPROTECT(1);
567552
return newx;
568553
}

0 commit comments

Comments
 (0)