diff --git a/src/helper_functions.cpp b/src/helper_functions.cpp index 14d49df1e..3dd490ee1 100644 --- a/src/helper_functions.cpp +++ b/src/helper_functions.cpp @@ -353,30 +353,31 @@ SEXP dims_to_df(Rcpp::IntegerVector rows, Rcpp::CharacterVector cols, Rcpp::Null SET_VECTOR_ELT(df, i, Rcpp::CharacterVector(nn, NA_STRING)); } - if (has_filled && fill) { - - std::vector flld = Rcpp::as>(filled.get()); - std::unordered_set flls(flld.begin(), flld.end()); - - // with has_filled we always have to run this loop - for (size_t i = 0; i < kk; ++i) { - Rcpp::CharacterVector cvec = Rcpp::as(df[i]); - std::string coli = Rcpp::as(cols[i]); - for (size_t j = 0; j < nn; ++j) { - std::string cell = coli + std::to_string(rows[j]); - if (has_cell(cell, flls)) - cvec[j] = coli + std::to_string(rows[j]); - // else cvec[j] = ""; + if (fill) { + if (has_filled) { + + std::vector flld = Rcpp::as>(filled.get()); + std::unordered_set flls(flld.begin(), flld.end()); + + // with has_filled we always have to run this loop + for (size_t i = 0; i < kk; ++i) { + Rcpp::CharacterVector cvec = Rcpp::as(df[i]); + std::string coli = Rcpp::as(cols[i]); + for (size_t j = 0; j < nn; ++j) { + std::string cell = coli + std::to_string(rows[j]); + if (has_cell(cell, flls)) + cvec[j] = cell; + } } - } - } else if (fill) { // insert cells into data frame + } else { // insert cells into data frame - for (size_t i = 0; i < kk; ++i) { - Rcpp::CharacterVector cvec = Rcpp::as(df[i]); - std::string coli = Rcpp::as(cols[i]); - for (size_t j = 0; j < nn; ++j) { - cvec[j] = coli + std::to_string(rows[j]); + for (size_t i = 0; i < kk; ++i) { + Rcpp::CharacterVector cvec = Rcpp::as(df[i]); + std::string coli = Rcpp::as(cols[i]); + for (size_t j = 0; j < nn; ++j) { + cvec[j] = coli + std::to_string(rows[j]); + } } }