cpp11
cpp11 copied to clipboard
`as_sexp_strings()` could use a single `unwind_protect()` around the loop
trafficstars
To convert from std::vector<std::string> to cpp11::strings you might do cpp11::strings(as_sexp(x)). That goes through as_sexp_strings() which looks like it could be a little more efficient. Rather than calling safe[Rf_mkCharCE] on each iteration, I think we could wrap the whole loop in a single unwind_protect().
https://github.com/r-lib/cpp11/blob/05c888b0c6f49e7b252b79b028e4719e6d5b299d/inst/include/cpp11/as.hpp#L287-L306
Something like https://github.com/r-lib/cpp11/blob/05c888b0c6f49e7b252b79b028e4719e6d5b299d/vignettes/FAQ.Rmd#L499-L503
Be careful to avoid all the pitfalls of calling unwind_protect() manually that are mentioned in that vignette