Skip to content

Commit

Permalink
pull out len neatly
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilHvitfeldt committed Apr 29, 2024
1 parent 33dbebf commit 2f72845
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/altrep-sparse-real.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,15 @@ Rboolean altrep_sparse_real_Inspect(SEXP x,
// ALTREAL

static double altrep_sparse_real_Elt(SEXP x, R_xlen_t i) {

if (i > Rf_asReal(VECTOR_ELT(R_altrep_data1(x), 2))) {
return NA_REAL;
}

SEXP data1 = R_altrep_data1(x);
SEXP val = VECTOR_ELT(data1, 0);
SEXP pos = VECTOR_ELT(data1, 1);
SEXP len = VECTOR_ELT(data1, 2);
R_xlen_t c_len = (R_xlen_t) INTEGER_ELT(len, 0);

if (i > c_len) {
return NA_REAL;
}

const R_xlen_t n = Rf_xlength(val);

Expand Down

0 comments on commit 2f72845

Please sign in to comment.