Skip to content

Commit ee6ceb6

Browse files
committed
Fix for NA handling in IndexHasher
1 parent 646e21c commit ee6ceb6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

inst/include/Rcpp/hash/IndexHash.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,20 +159,25 @@ namespace Rcpp{
159159
#endif
160160
}
161161

162+
inline bool not_equal(STORAGE lhs, STORAGE rhs) {
163+
return ::Rcpp::traits::comparator_type<STORAGE>()(lhs, rhs);
164+
}
162165

163166
bool add_value(int i){
164167
RCPP_DEBUG_2( "%s::add_value(%d)", DEMANGLE(IndexHash), i )
165168
STORAGE val = src[i++] ;
166169
int addr = get_addr(val) ;
167-
while (data[addr] && src[data[addr] - 1] != val) {
170+
while (data[addr] && not_equal( src[data[addr] - 1], val)) {
168171
addr++;
169172
if (addr == m) addr = 0;
170173
}
171174
if (!data[addr]){
172175
data[addr] = i ;
173176
size_++ ;
177+
174178
return true ;
175179
}
180+
176181
return false;
177182
}
178183

0 commit comments

Comments
 (0)