diff rust/hg-core/examples/nodemap/main.rs @ 46495:6380efb82191

rust: replace Node::encode_hex with std::fmt::LowerHex This avoids allocating intermediate strings. Differential Revision: https://phab.mercurial-scm.org/D9860
author Simon Sapin <simon.sapin@octobus.net>
date Mon, 25 Jan 2021 12:00:23 +0100
parents 8f7c6656ac79
children 18a261b11b20
line wrap: on
line diff
--- a/rust/hg-core/examples/nodemap/main.rs	Fri Jan 29 13:46:19 2021 +0100
+++ b/rust/hg-core/examples/nodemap/main.rs	Mon Jan 25 12:00:23 2021 +0100
@@ -66,7 +66,7 @@
         .collect();
     if queries < 10 {
         let nodes_hex: Vec<String> =
-            nodes.iter().map(|n| n.encode_hex()).collect();
+            nodes.iter().map(|n| format!("{:x}", n)).collect();
         println!("Nodes: {:?}", nodes_hex);
     }
     let mut last: Option<Revision> = None;
@@ -76,11 +76,11 @@
     }
     let elapsed = start.elapsed();
     println!(
-        "Did {} queries in {:?} (mean {:?}), last was {:?} with result {:?}",
+        "Did {} queries in {:?} (mean {:?}), last was {:x} with result {:?}",
         queries,
         elapsed,
         elapsed / (queries as u32),
-        nodes.last().unwrap().encode_hex(),
+        nodes.last().unwrap(),
         last
     );
 }