File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed
Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change 1+ 2015-02-06 Kevin Ushey <kevinushey@gmail.com>
2+
3+ * inst/include/Rcpp/vector/Subsetter.h: compare CHARSXP pointers
4+ rather than string contents in subsetter
5+
162015-02-03 JJ Allaire <jj@rstudio.org>
27
38 * src/attributes.cpp: Simplify generated attributes code for
Original file line number Diff line number Diff line change @@ -141,20 +141,17 @@ class SubsetProxy {
141141 indices.reserve (rhs_n);
142142 SEXP names = Rf_getAttrib (lhs, R_NamesSymbol);
143143 if (Rf_isNull (names)) stop (" names is null" );
144- for (int i=0 ; i < rhs_n; ++i) {
145- indices.push_back ( find (names, CHAR ( STRING_ELT (rhs, i) )) );
144+ SEXP* namesPtr = STRING_PTR (names);
145+ SEXP* rhsPtr = STRING_PTR (rhs);
146+ for (int i = 0 ; i < rhs_n; ++i) {
147+ SEXP* match = std::find (namesPtr, namesPtr + lhs_n, *(rhsPtr + i));
148+ if (match == namesPtr + lhs_n)
149+ stop (" not found" );
150+ indices.push_back (match - namesPtr);
146151 }
147152 indices_n = indices.size ();
148153 }
149154
150- int find (const RHS_t& names, const char * str) {
151- for (int i=0 ; i < lhs_n; ++i) {
152- if (strcmp ( CHAR ( STRING_ELT ( names, i) ), str) == 0 ) return i;
153- }
154- stop (" no name found" );
155- return -1 ;
156- }
157-
158155 void get_indices ( traits::identity< traits::int2type<LGLSXP> > t ) {
159156 indices.reserve (rhs_n);
160157 if (lhs_n != rhs_n) {
You can’t perform that action at this time.
0 commit comments