Skip to content

Commit e2b02d2

Browse files
authored
refactor(oma-pm): use IndexMap to save search index (#100)
1 parent 4767537 commit e2b02d2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

oma-pm/src/search.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use ahash::{AHashMap, RandomState};
22
use cxx::UniquePtr;
33
use glob_match::glob_match;
4+
use indexmap::map::Entry;
45
use indicium::simple::{Indexable, SearchIndex};
56
use memchr::memmem;
67
use oma_apt::{
@@ -9,9 +10,10 @@ use oma_apt::{
910
raw::{IntoRawIter, PkgIterator},
1011
Package, Version,
1112
};
12-
use std::{collections::hash_map::Entry, fmt::Debug};
13+
use std::fmt::Debug;
1314

1415
type IndexSet<T> = indexmap::IndexSet<T, RandomState>;
16+
type IndexMap<K, V> = indexmap::IndexMap<K, V, RandomState>;
1517

1618
use crate::{
1719
format_description,
@@ -119,7 +121,7 @@ pub struct SearchResult {
119121

120122
pub struct IndiciumSearch<'a> {
121123
cache: &'a Cache,
122-
pkg_map: AHashMap<String, SearchEntry>,
124+
pkg_map: IndexMap<String, SearchEntry>,
123125
index: SearchIndex<String>,
124126
}
125127

@@ -160,7 +162,7 @@ impl<'a> IndiciumSearch<'a> {
160162
let sort = PackageSort::default().include_virtual();
161163
let packages = cache.packages(&sort);
162164

163-
let mut pkg_map = AHashMap::new();
165+
let mut pkg_map = IndexMap::with_hasher(RandomState::new());
164166

165167
for (i, pkg) in packages.enumerate() {
166168
let name = pkg.fullname(true);

0 commit comments

Comments
 (0)