mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 03:55:07 +08:00
Fix iterating on hashmap entries
This commit is contained in:
parent
15bf556291
commit
97d2860998
@ -44,9 +44,9 @@ impl HashMapMerger {
|
|||||||
self.maps.extend(iter);
|
self.maps.extend(iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter<'h>(&'h self) -> Iter<'h> {
|
pub fn iter(&self) -> Iter<'_> {
|
||||||
let mut entries: Vec<_> =
|
let mut entries: Vec<_> =
|
||||||
self.maps.iter().map(|m| m.iter()).flatten().map(|(k, v)| (k.as_slice(), v)).collect();
|
self.maps.iter().flat_map(|m| m.iter()).map(|(k, v)| (k.as_slice(), v)).collect();
|
||||||
entries.par_sort_unstable_by_key(|(key, _)| *key);
|
entries.par_sort_unstable_by_key(|(key, _)| *key);
|
||||||
Iter {
|
Iter {
|
||||||
sorted_entries: entries.into_iter(),
|
sorted_entries: entries.into_iter(),
|
||||||
@ -74,7 +74,9 @@ impl<'h> Iterator for Iter<'h> {
|
|||||||
} else {
|
} else {
|
||||||
let previous_key = self.current_key.replace(k);
|
let previous_key = self.current_key.replace(k);
|
||||||
let previous_deladd = mem::replace(&mut self.current_deladd, other.clone());
|
let previous_deladd = mem::replace(&mut self.current_deladd, other.clone());
|
||||||
return previous_key.map(|ck| (ck, previous_deladd));
|
if let Some(previous_key) = previous_key {
|
||||||
|
return Some((previous_key, previous_deladd));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
|
Loading…
Reference in New Issue
Block a user