# HG changeset patch # User Rapha?l Gom?s # Date 1740164171 18000 # Node ID 155e1e8dc055ccb82d291fdb53fac8e8dcbf010a # Parent 33e06272ff1a225ba5e9fb1bdb8a12c3d9f78a64 rust-nodemap: don't compute the error string unless needed This is... really dumb and costs a ton of performance in a hot loop. It was 75% of a profile for a tip to null p1 node traversal in pure Rust. I'm at fault, done in 652149ed64f08ee73e8fd2f76aa480ea8820fe08. I thought clippy had a lint for this, but apparently not? diff -r 33e06272ff1a -r 155e1e8dc055 rust/hg-core/src/revlog/mod.rs --- a/rust/hg-core/src/revlog/mod.rs Thu Feb 20 11:44:44 2025 +0100 +++ b/rust/hg-core/src/revlog/mod.rs Fri Feb 21 13:56:11 2025 -0500 @@ -374,7 +374,9 @@ nodemap .find_bin(self.index(), node) .map_err(|err| (err, format!("{:x}", node)))? - .ok_or(RevlogError::InvalidRevision(format!("{:x}", node))) + .ok_or_else(|| { + RevlogError::InvalidRevision(format!("{:x}", node)) + }) } else { self.index().rev_from_node_no_persistent_nodemap(node) }