Skip to content

Making things a little bit faster #458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
3 changes: 1 addition & 2 deletions inst/include/cpp11/data_frame.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include <cstdlib> // for abs
#include <cstdlib>
#include <cstdlib> // for abs
#include <initializer_list> // for initializer_list
#include <string> // for string, basic_string
#include <utility> // for move
Expand Down
2 changes: 1 addition & 1 deletion inst/include/cpp11/external_pointer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class external_pointer {

T* ptr = static_cast<T*>(R_ExternalPtrAddr(p));

if (ptr == NULL) {
if (ptr == nullptr) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion inst/include/cpp11/function.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <string.h> // for strcmp
#include <cstring> // for std::strcmp (@pachadotdev use std qualifiers)

#include <cstdio> // for snprintf
#include <string> // for string, basic_string
Expand Down
5 changes: 4 additions & 1 deletion inst/include/cpp11/list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ inline r_vector<SEXP>::r_vector(std::initializer_list<named_arg> il)
: cpp11::r_vector<SEXP>(safe[Rf_allocVector](VECSXP, il.size())),
capacity_(il.size()) {
unwind_protect([&] {
SEXP names = Rf_allocVector(STRSXP, capacity_);
SEXP names;
PROTECT(names = Rf_allocVector(STRSXP, capacity_));
Rf_setAttrib(data_, R_NamesSymbol, names);

auto it = il.begin();
Expand All @@ -91,6 +92,8 @@ inline r_vector<SEXP>::r_vector(std::initializer_list<named_arg> il)
SEXP name = Rf_mkCharCE(it->name(), CE_UTF8);
SET_STRING_ELT(names, i, name);
}

UNPROTECT(1);
});
}

Expand Down
5 changes: 4 additions & 1 deletion inst/include/cpp11/r_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,8 @@ inline r_vector<T>::r_vector(std::initializer_list<named_arg> il)
}

unwind_protect([&] {
SEXP names = Rf_allocVector(STRSXP, capacity_);
SEXP names;
PROTECT(names = Rf_allocVector(STRSXP, capacity_));
Rf_setAttrib(data_, R_NamesSymbol, names);

auto it = il.begin();
Expand All @@ -890,6 +891,8 @@ inline r_vector<T>::r_vector(std::initializer_list<named_arg> il)
SEXP name = Rf_mkCharCE(it->name(), CE_UTF8);
SET_STRING_ELT(names, i, name);
}

UNPROTECT(1);
});
}

Expand Down