Skip to content

Commit fb955fd

Browse files
authored
Merge pull request #30 from pachadotdev/compilationspeed
Compilationspeed
2 parents cbdd514 + ddf5300 commit fb955fd

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

inst/include/cpp11/data_frame.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22

3-
#include <cstdlib> // for abs
4-
#include <cstdlib>
3+
#include <cstdlib> // for abs
54
#include <initializer_list> // for initializer_list
65
#include <string> // for string, basic_string
76
#include <utility> // for move

inst/include/cpp11/external_pointer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class external_pointer {
3838

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

41-
if (ptr == NULL) {
41+
if (ptr == nullptr) {
4242
return;
4343
}
4444

inst/include/cpp11/function.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

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

55
#include <cstdio> // for snprintf
66
#include <string> // for string, basic_string

inst/include/cpp11/list.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ inline r_vector<SEXP>::r_vector(std::initializer_list<named_arg> il)
7979
: cpp11::r_vector<SEXP>(safe[Rf_allocVector](VECSXP, il.size())),
8080
capacity_(il.size()) {
8181
unwind_protect([&] {
82-
SEXP names = Rf_allocVector(STRSXP, capacity_);
82+
SEXP names;
83+
PROTECT(names = Rf_allocVector(STRSXP, capacity_));
8384
Rf_setAttrib(data_, R_NamesSymbol, names);
8485

8586
auto it = il.begin();
@@ -91,6 +92,8 @@ inline r_vector<SEXP>::r_vector(std::initializer_list<named_arg> il)
9192
SEXP name = Rf_mkCharCE(it->name(), CE_UTF8);
9293
SET_STRING_ELT(names, i, name);
9394
}
95+
96+
UNPROTECT(1);
9497
});
9598
}
9699

inst/include/cpp11/r_vector.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,8 @@ inline r_vector<T>::r_vector(std::initializer_list<named_arg> il)
874874
}
875875

876876
unwind_protect([&] {
877-
SEXP names = Rf_allocVector(STRSXP, capacity_);
877+
SEXP names;
878+
PROTECT(names = Rf_allocVector(STRSXP, capacity_));
878879
Rf_setAttrib(data_, R_NamesSymbol, names);
879880

880881
auto it = il.begin();
@@ -899,6 +900,8 @@ inline r_vector<T>::r_vector(std::initializer_list<named_arg> il)
899900
SEXP name = Rf_mkCharCE(it->name(), CE_UTF8);
900901
SET_STRING_ELT(names, i, name);
901902
}
903+
904+
UNPROTECT(1);
902905
});
903906
}
904907

0 commit comments

Comments
 (0)