File tree Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -159,8 +159,8 @@ namespace Rcpp{
159
159
#endif
160
160
}
161
161
162
- inline bool not_equal (STORAGE lhs, STORAGE rhs) {
163
- return ::Rcpp::traits::comparator_type <STORAGE>()(lhs, rhs);
162
+ inline bool not_equal (const STORAGE& lhs, const STORAGE& rhs) {
163
+ return ! ::Rcpp::traits::equal_type <STORAGE>()(lhs, rhs);
164
164
}
165
165
166
166
bool add_value (int i){
@@ -169,15 +169,17 @@ namespace Rcpp{
169
169
int addr = get_addr (val) ;
170
170
while (data[addr] && not_equal ( src[data[addr] - 1 ], val)) {
171
171
addr++;
172
- if (addr == m) addr = 0 ;
172
+ if (addr == m) {
173
+ addr = 0 ;
174
+ }
173
175
}
176
+
174
177
if (!data[addr]){
175
178
data[addr] = i ;
176
179
size_++ ;
177
180
178
181
return true ;
179
182
}
180
-
181
183
return false ;
182
184
}
183
185
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ inline int StrCmp(SEXP x, SEXP y) {
46
46
if (x == NA_STRING) return (y == NA_STRING ? 0 : 1 );
47
47
if (y == NA_STRING) return -1 ;
48
48
if (x == y) return 0 ; // same string in cache
49
- return strcmp (CHAR (x), CHAR (y));
49
+ return strcmp (char_nocheck (x), char_nocheck (y));
50
50
}
51
51
52
52
template <typename T>
@@ -91,7 +91,21 @@ struct comparator_type<SEXP> {
91
91
inline bool operator ()(SEXP left, SEXP right) const {
92
92
return StrCmp (left, right) < 0 ;
93
93
}
94
- };
94
+ };
95
+
96
+ template <typename T>
97
+ struct equal_type {
98
+ inline bool operator ()(T left, T right) const {
99
+ return left == right;
100
+ }
101
+ };
102
+
103
+ template <>
104
+ struct equal_type <double > {
105
+ inline bool operator ()(double left, double right) const {
106
+ return memcmp (&left, &right, sizeof (double )) == 0 ;
107
+ }
108
+ };
95
109
96
110
}
97
111
}
You can’t perform that action at this time.
0 commit comments