@@ -1225,37 +1225,6 @@ impl<A: Allocator + Clone> RawTableInner<A> {
1225
1225
}
1226
1226
}
1227
1227
1228
- /// Searches for an element in the table, stopping at the group where `stop` returns `Some` and
1229
- /// no elements matched. Returns the bucket that matches or the result of `stop`.
1230
- #[ inline]
1231
- unsafe fn search (
1232
- & self ,
1233
- hash : u64 ,
1234
- eq : & mut dyn FnMut ( usize ) -> bool ,
1235
- mut stop : impl FnMut ( & Group , & ProbeSeq ) -> Option < usize > ,
1236
- ) -> ( usize , bool ) {
1237
- let h2_hash = h2 ( hash) ;
1238
- let mut probe_seq = self . probe_seq ( hash) ;
1239
-
1240
- loop {
1241
- let group = Group :: load ( self . ctrl ( probe_seq. pos ) ) ;
1242
-
1243
- for bit in group. match_byte ( h2_hash) . into_iter ( ) {
1244
- let index = ( probe_seq. pos + bit) & self . bucket_mask ;
1245
-
1246
- if likely ( eq ( index) ) {
1247
- return ( index, true ) ;
1248
- }
1249
- }
1250
-
1251
- if let Some ( stop) = stop ( & group, & probe_seq) {
1252
- return ( stop, false ) ;
1253
- }
1254
-
1255
- probe_seq. move_next ( self . bucket_mask ) ;
1256
- }
1257
- }
1258
-
1259
1228
/// Finds the position to insert something in a group.
1260
1229
#[ inline]
1261
1230
unsafe fn find_insert_slot_in_group (
@@ -1301,29 +1270,42 @@ impl<A: Allocator + Clone> RawTableInner<A> {
1301
1270
) -> ( usize , bool ) {
1302
1271
unsafe {
1303
1272
let mut tombstone = None ;
1304
- self . search ( hash, eq, |group, probe_seq| {
1305
- let index = self . find_insert_slot_in_group ( group, probe_seq) ;
1273
+
1274
+ let h2_hash = h2 ( hash) ;
1275
+ let mut probe_seq = self . probe_seq ( hash) ;
1276
+
1277
+ loop {
1278
+ let group = Group :: load ( self . ctrl ( probe_seq. pos ) ) ;
1279
+
1280
+ for bit in group. match_byte ( h2_hash) . into_iter ( ) {
1281
+ let index = ( probe_seq. pos + bit) & self . bucket_mask ;
1282
+
1283
+ if likely ( eq ( index) ) {
1284
+ return ( index, true ) ;
1285
+ }
1286
+ }
1287
+
1288
+ let index = self . find_insert_slot_in_group ( & group, & probe_seq) ;
1306
1289
1307
1290
if likely ( index. is_some ( ) ) {
1308
1291
// Only stop the search if the group is empty. The element might be
1309
1292
// in a following group.
1310
1293
if likely ( group. match_empty ( ) . any_bit_set ( ) ) {
1311
1294
// Use a tombstone if we found one
1312
- if unlikely ( tombstone. is_some ( ) ) {
1313
- tombstone
1295
+ return if unlikely ( tombstone. is_some ( ) ) {
1296
+ ( tombstone. unwrap ( ) , false )
1314
1297
} else {
1315
- index
1316
- }
1298
+ ( index. unwrap ( ) , false )
1299
+ } ;
1317
1300
} else {
1318
1301
// We found a tombstone, record it so we can return it as a potential
1319
1302
// insertion location.
1320
1303
tombstone = index;
1321
- None
1322
1304
}
1323
- } else {
1324
- None
1325
1305
}
1326
- } )
1306
+
1307
+ probe_seq. move_next ( self . bucket_mask ) ;
1308
+ }
1327
1309
}
1328
1310
}
1329
1311
0 commit comments