Mercurial > public > mercurial-scm > hg
comparison rust/hg-core/examples/nodemap/main.rs @ 46432:18a261b11b20
rust: Remove hex parsing from the nodemap
Separating concerns simplifies error types.
Differential Revision: https://phab.mercurial-scm.org/D9864
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Mon, 25 Jan 2021 18:25:26 +0100 |
parents | 6380efb82191 |
children | e834b79def74 |
comparison
equal
deleted
inserted
replaced
46431:645ee7225fab | 46432:18a261b11b20 |
---|---|
47 Ok(()) | 47 Ok(()) |
48 } | 48 } |
49 | 49 |
50 fn query(index: &Index, nm: &NodeTree, prefix: &str) { | 50 fn query(index: &Index, nm: &NodeTree, prefix: &str) { |
51 let start = Instant::now(); | 51 let start = Instant::now(); |
52 let res = nm.find_hex(index, prefix); | 52 let res = NodePrefix::from_hex(prefix).map(|p| nm.find_bin(index, p)); |
53 println!("Result found in {:?}: {:?}", start.elapsed(), res); | 53 println!("Result found in {:?}: {:?}", start.elapsed(), res); |
54 } | 54 } |
55 | 55 |
56 fn bench(index: &Index, nm: &NodeTree, queries: usize) { | 56 fn bench(index: &Index, nm: &NodeTree, queries: usize) { |
57 let len = index.len() as u32; | 57 let len = index.len() as u32; |