We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 05c888b + 9851423 commit 72d2f37Copy full SHA for 72d2f37
inst/include/cpp11/as.hpp
@@ -287,18 +287,14 @@ template <typename Container, typename AsCstring>
287
SEXP as_sexp_strings(const Container& from, AsCstring&& c_str) {
288
R_xlen_t size = from.size();
289
290
- SEXP data;
291
- try {
292
- data = PROTECT(safe[Rf_allocVector](STRSXP, size));
+ SEXP data = PROTECT(safe[Rf_allocVector](STRSXP, size));
293
+ unwind_protect([&] {
294
auto it = from.begin();
295
for (R_xlen_t i = 0; i < size; ++i, ++it) {
296
- SET_STRING_ELT(data, i, safe[Rf_mkCharCE](c_str(*it), CE_UTF8));
+ SET_STRING_ELT(data, i, Rf_mkCharCE(c_str(*it), CE_UTF8));
297
}
298
- } catch (const unwind_exception& e) {
299
- UNPROTECT(1);
300
- throw e;
301
- }
+ });
302
303
UNPROTECT(1);
304
return data;
0 commit comments