Skip to content

Commit 5caf9cc

Browse files
committed
maxLength: return xlength if non-resizable
That's what the function does in R-devel.
1 parent af91fe9 commit 5caf9cc

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/data.table.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,13 @@
9292
# define R_allocResizableVector(type, maxlen) R_allocResizableVector_(type, maxlen)
9393
# define R_duplicateAsResizable(x) R_duplicateAsResizable_(x)
9494
# define R_resizeVector(x, newlen) SETLENGTH(x, newlen)
95-
# define R_maxLength(x) TRUELENGTH(x)
95+
# define R_maxLength(x) R_maxLength_(x)
96+
static inline R_xlen_t R_maxLength_(SEXP x) {
97+
return IS_GROWABLE(x) ? TRUELENGTH(x) : XLENGTH(x);
98+
}
9699
# define R_isResizable(x) R_isResizable_(x)
97100
static inline bool R_isResizable_(SEXP x) {
98-
// IS_GROWABLE also checks for TRUELENGTH < XLENGTH
101+
// IS_GROWABLE also checks for XLENGTH < TRUELENGTH
99102
return (LEVELS(x) & 0x20) && TRUELENGTH(x);
100103
}
101104
#endif

0 commit comments

Comments
 (0)