Skip to content

Commit c6781bd

Browse files
Also dispatch in dim.data.table()
1 parent 3aa45b9 commit c6781bd

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

src/assign.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ SEXP setdt_nrows(SEXP x)
239239
len_xi = INTEGER(dim_xi)[0];
240240
} else {
241241
// Be sure to do length() dispatch, #4800
242-
len_xi = INTEGER(length_with_dispatch(xi))[0];
242+
len_xi = length_with_dispatch(xi);
243243
}
244244
if (!base_length) {
245245
base_length = len_xi;

src/data.table.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ SEXP islockedR(SEXP x);
258258
bool need2utf8(SEXP x);
259259
SEXP coerceUtf8IfNeeded(SEXP x);
260260
SEXP coerceAs(SEXP x, SEXP as, SEXP copyArg);
261+
int length_with_dispatch(SEXP);
261262
void internal_error(const char *call_name, const char *format, ...);
262263

263264
// types.c
@@ -350,6 +351,5 @@ SEXP test_dt_win_snprintf(void);
350351
SEXP dt_zlib_version(void);
351352
SEXP dt_has_zlib(void);
352353
SEXP startsWithAny(SEXP, SEXP, SEXP);
353-
SEXP length_with_dispatch(SEXP);
354354
SEXP convertDate(SEXP, SEXP);
355355
SEXP fastmean(SEXP);

src/utils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,8 @@ SEXP startsWithAny(const SEXP x, const SEXP y, SEXP start) {
449449
return ScalarLogical(false);
450450
}
451451

452-
SEXP length_with_dispatch(SEXP x) {
453-
SEXP l = PROTECT(eval(PROTECT(lang2(install("length"), x)), R_GlobalEnv));
452+
int length_with_dispatch(SEXP x) {
453+
int l = INTEGER(PROTECT(eval(PROTECT(lang2(install("length"), x)), R_GlobalEnv)))[0];
454454
UNPROTECT(2);
455455
return l;
456456
}

src/wrappers.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ SEXP dim(SEXP x)
113113
INTEGER(ans)[1] = 0;
114114
}
115115
else {
116-
INTEGER(ans)[0] = length(VECTOR_ELT(x, 0));
116+
// Column class might require dispatch to get length() correct
117+
INTEGER(ans)[0] = length_with_dispatch(VECTOR_ELT(x, 0));
117118
INTEGER(ans)[1] = length(x);
118119
}
119120
UNPROTECT(1);

0 commit comments

Comments
 (0)