Skip to content

Commit 66d37b1

Browse files
authored
Merge pull request #6 from pachadotdev/compilationspeed
Compilationspeed
2 parents 8e7a80d + ddf5300 commit 66d37b1

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
@@ -876,7 +876,8 @@ inline r_vector<T>::r_vector(std::initializer_list<named_arg> il)
876876
}
877877

878878
unwind_protect([&] {
879-
SEXP names = Rf_allocVector(STRSXP, capacity_);
879+
SEXP names;
880+
PROTECT(names = Rf_allocVector(STRSXP, capacity_));
880881
Rf_setAttrib(data_, R_NamesSymbol, names);
881882

882883
auto it = il.begin();
@@ -901,6 +902,8 @@ inline r_vector<T>::r_vector(std::initializer_list<named_arg> il)
901902
SEXP name = Rf_mkCharCE(it->name(), CE_UTF8);
902903
SET_STRING_ELT(names, i, name);
903904
}
905+
906+
UNPROTECT(1);
904907
});
905908
}
906909

0 commit comments

Comments
 (0)