# HG changeset patch # User Arseniy Alekseyev # Date 2023-02-17 13:29:39 # Node ID 6ea3b1acb5de12a7f44d9bc562894113914660c4 # Parent 4180c988d1d5b2d31fd7c51e14c541dfc216fa9f rhg: in path_encode, be a bit more conservative about memory usage Use [shrink_to_fit] to match the previous behavior more closely, and potentially save (a tiny bit) of memory. FWIW, I suspect this is unnecessary, but this whole MR is about simplifying things while preserving any existing optimizations. diff --git a/rust/hg-core/src/revlog/path_encode.rs b/rust/hg-core/src/revlog/path_encode.rs --- a/rust/hg-core/src/revlog/path_encode.rs +++ b/rust/hg-core/src/revlog/path_encode.rs @@ -576,6 +576,7 @@ fn hash_mangle(src: &[u8], sha: &[u8]) - if let Some(l) = last_dot { dest.write_bytes(&src[l..]); } + dest.shrink_to_fit(); dest }