rhg: use generic DestArr in hash_mangle
This simplifies code a bit more, but comes with an extra memory copy
in case [destlen == dest_vec.len()].
This is probably fine, but a follow-up change is removing that too.
--- a/rust/hg-core/src/revlog/path_encode.rs Thu Feb 16 18:45:23 2023 +0000
+++ b/rust/hg-core/src/revlog/path_encode.rs Thu Feb 16 18:46:44 2023 +0000
@@ -545,8 +545,7 @@
src[s..].iter().rposition(|b| *b == b'.').map(|i| i + s)
};
- let mut dest_vec = vec![0; MAXSTOREPATHLEN];
- let mut dest = Dest::create(&mut dest_vec);
+ let mut dest : DestArr<MAXSTOREPATHLEN> = DestArr::create();
dest.write_bytes(b"dh/");
if let Some(last_slash) = last_slash {
@@ -590,13 +589,7 @@
if let Some(l) = last_dot {
dest.write_bytes(&src[l..]);
}
- let destlen = dest.len;
- if destlen == dest_vec.len() {
- dest_vec
- } else {
- // sometimes the path are shorter than MAXSTOREPATHLEN
- dest_vec[..destlen].to_vec()
- }
+ dest.contents().to_vec()
}
fn hash_encode(src: &[u8]) -> Vec<u8> {