File tree Expand file tree Collapse file tree 1 file changed +3
-11
lines changed
Expand file tree Collapse file tree 1 file changed +3
-11
lines changed Original file line number Diff line number Diff line change @@ -67,23 +67,15 @@ inline void r_vector<r_string>::set_elt(
6767 SET_STRING_ELT (x, i, value);
6868}
6969
70- // Pacha: Optimized subscript assignment for std::string
71- template <>
72- inline typename r_vector<r_string>::proxy r_vector<r_string>::operator [](
73- R_xlen_t i) const {
74- return typename r_vector<r_string>::proxy (data_, i, nullptr , false );
75- }
76-
77- // Pacha: Optimized push_back for std::string
70+ // Pacha: Optimized push_back for std::string (borrows from @traversc' push_back_fast)
7871template <>
7972template <typename U, typename std::enable_if<std::is_same<U, r_string>::value>::type*>
8073inline void r_vector<r_string>::push_back(const std::string& value) {
8174 while (this ->length_ >= this ->capacity_ ) {
8275 this ->reserve (this ->capacity_ == 0 ? 1 : this ->capacity_ * 2 );
8376 }
84-
85- SEXP char_sexp = Rf_mkCharLenCE (value.c_str (), value.size (), CE_UTF8);
86- SET_STRING_ELT (this ->data_ , this ->length_ , char_sexp);
77+ set_elt (this ->data_ , this ->length_ ,
78+ Rf_mkCharLenCE (value.c_str (), value.size (), CE_UTF8));
8779 ++this ->length_ ;
8880}
8981
You can’t perform that action at this time.
0 commit comments