Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2020-04-25 Dirk Eddelbuettel <edd@debian.org>

* inst/include/Rcpp/sugar/functions/sample.h: Replace R_alloc() with
a standard vector allocation to reduce memory consumption in sample

2020-04-16 Dirk Eddelbuettel <edd@debian.org>

* DESCRIPTION (Version, Date): Roll minor version
Expand Down
5 changes: 5 additions & 0 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
\item The exceptions test is now partially skipped on Solaris as
it already is on Windows (Dirk in \ghpr{1065}).
}
\item Changes in Rcpp Sugar:
\itemize{
\item Two \code{sample()} objects are now standard vectors and not
\code{R_alloc} created (Dirk in \ghpr{1075} fixing \ghpr{1074}).
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions inst/include/Rcpp/sugar/functions/sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ inline Vector<INTSXP> EmpiricalSample(int n, int size, bool replace, bool one_ba
return ans;
}

int* x = reinterpret_cast<int*>(R_alloc(n, sizeof(int)));
IntegerVector x = no_init(n);
for (int i = 0; i < n; i++) {
x[i] = i;
}
Expand Down Expand Up @@ -378,7 +378,7 @@ inline Vector<RTYPE> EmpiricalSample(int size, bool replace, const Vector<RTYPE>
return ans;
}

int* x = reinterpret_cast<int*>(R_alloc(n, sizeof(int)));
IntegerVector x = no_init(n);
for (int i = 0; i < n; i++) {
x[i] = i;
}
Expand Down