@@ -4,7 +4,6 @@ use std::mem;
4
4
use super :: { Addr , MemoryArena } ;
5
5
use crate :: fastcpy:: fast_short_slice_copy;
6
6
use crate :: memory_arena:: store;
7
- use crate :: UnorderedId ;
8
7
9
8
/// Returns the actual memory size in bytes
10
9
/// required to create a table with a given capacity.
@@ -26,22 +25,20 @@ type HashType = u64;
26
25
struct KeyValue {
27
26
key_value_addr : Addr ,
28
27
hash : HashType ,
29
- unordered_id : UnorderedId ,
30
28
}
31
29
32
30
impl Default for KeyValue {
33
31
fn default ( ) -> Self {
34
32
KeyValue {
35
33
key_value_addr : Addr :: null_pointer ( ) ,
36
34
hash : 0 ,
37
- unordered_id : UnorderedId :: default ( ) ,
38
35
}
39
36
}
40
37
}
41
38
42
39
impl KeyValue {
43
40
#[ inline]
44
- fn is_empty ( self ) -> bool {
41
+ fn is_empty ( & self ) -> bool {
45
42
self . key_value_addr . is_null ( )
46
43
}
47
44
#[ inline]
@@ -96,12 +93,12 @@ pub struct Iter<'a> {
96
93
}
97
94
98
95
impl < ' a > Iterator for Iter < ' a > {
99
- type Item = ( & ' a [ u8 ] , Addr , UnorderedId ) ;
96
+ type Item = ( & ' a [ u8 ] , Addr ) ;
100
97
101
98
fn next ( & mut self ) -> Option < Self :: Item > {
102
99
self . inner . next ( ) . map ( move |kv| {
103
100
let ( key, offset) : ( & ' a [ u8 ] , Addr ) = self . hashmap . get_key_value ( kv. key_value_addr ) ;
104
- ( key, offset, kv . unordered_id )
101
+ ( key, offset)
105
102
} )
106
103
}
107
104
}
@@ -207,16 +204,13 @@ impl ArenaHashMap {
207
204
}
208
205
209
206
#[ inline]
210
- fn set_bucket ( & mut self , hash : HashType , key_value_addr : Addr , bucket : usize ) -> UnorderedId {
211
- let unordered_id = self . len as UnorderedId ;
207
+ fn set_bucket ( & mut self , hash : HashType , key_value_addr : Addr , bucket : usize ) {
212
208
self . len += 1 ;
213
209
214
210
self . table [ bucket] = KeyValue {
215
211
key_value_addr,
216
212
hash,
217
- unordered_id,
218
213
} ;
219
- unordered_id
220
214
}
221
215
222
216
#[ inline]
@@ -290,14 +284,8 @@ impl ArenaHashMap {
290
284
/// If the key already as an associated value, then it will be passed
291
285
/// `Some(previous_value)`.
292
286
#[ inline]
293
- pub fn mutate_or_create < V > (
294
- & mut self ,
295
- key : & [ u8 ] ,
296
- mut updater : impl FnMut ( Option < V > ) -> V ,
297
- ) -> UnorderedId
298
- where
299
- V : Copy + ' static ,
300
- {
287
+ pub fn mutate_or_create < V > ( & mut self , key : & [ u8 ] , mut updater : impl FnMut ( Option < V > ) -> V )
288
+ where V : Copy + ' static {
301
289
if self . is_saturated ( ) {
302
290
self . resize ( ) ;
303
291
}
@@ -320,14 +308,15 @@ impl ArenaHashMap {
320
308
store ( & mut data[ stop..] , val) ;
321
309
}
322
310
323
- return self . set_bucket ( hash, key_addr, bucket) ;
311
+ self . set_bucket ( hash, key_addr, bucket) ;
312
+ return ;
324
313
}
325
314
if kv. hash == hash {
326
315
if let Some ( val_addr) = self . get_value_addr_if_key_match ( key, kv. key_value_addr ) {
327
316
let v = self . memory_arena . read ( val_addr) ;
328
317
let new_v = updater ( Some ( v) ) ;
329
318
self . memory_arena . write_at ( val_addr, new_v) ;
330
- return kv . unordered_id ;
319
+ return ;
331
320
}
332
321
}
333
322
// This allows fetching the next bucket before the loop jmp
@@ -361,7 +350,7 @@ mod tests {
361
350
} ) ;
362
351
let mut vanilla_hash_map = HashMap :: new ( ) ;
363
352
let iter_values = hash_map. iter ( ) ;
364
- for ( key, addr, _ ) in iter_values {
353
+ for ( key, addr) in iter_values {
365
354
let val: u32 = hash_map. memory_arena . read ( addr) ;
366
355
vanilla_hash_map. insert ( key. to_owned ( ) , val) ;
367
356
}
@@ -390,7 +379,7 @@ mod tests {
390
379
}
391
380
let mut terms_back: Vec < String > = hash_map
392
381
. iter ( )
393
- . map ( |( bytes, _, _ ) | String :: from_utf8 ( bytes. to_vec ( ) ) . unwrap ( ) )
382
+ . map ( |( bytes, _) | String :: from_utf8 ( bytes. to_vec ( ) ) . unwrap ( ) )
394
383
. collect ( ) ;
395
384
terms_back. sort ( ) ;
396
385
terms. sort ( ) ;
0 commit comments