Showing the changes to git-odb/src (1 of 4 files). Show all
Unified · Split
| @@ -3,7 +3,6 @@ use crate::{ · 2 unmodified lines | ||
| 3 | 3 | zlib, |
| 4 | 4 | }; |
| 5 | 5 | use git_object as object; |
| 6 | −use hex::ToHex; | |
| 7 | 6 | use object::borrowed; |
| 8 | 7 | use quick_error::quick_error; |
| 9 | 8 | use smallvec::SmallVec; |
| @@ -128,21 +127,9 @@ pub fn parse_header(input: &[u8]) -> Result<(object::Kind, usize, usize), Error> · 118 unmodified lines | ||
| 128 | 127 | } |
| 129 | 128 | |
| 130 | 129 | fn sha1_path(id: &[u8; 20], mut root: PathBuf) -> PathBuf { |
| 131 | − struct Buf([u8; 40], usize); | |
| 132 | − let mut buf = Buf([0u8; 40], 0); | |
| 133 | − | |
| 134 | − impl std::fmt::Write for Buf { | |
| 135 | − fn write_str(&mut self, s: &str) -> std::fmt::Result { | |
| 136 | − self.0[self.1..self.1 + buf.len()].copy_from_slice(buf); | |
| 137 | − self.1 += buf.len(); | |
| 138 | − Ok(()) | |
| 139 | − } | |
| 140 | − } | |
| 141 | − | |
| 142 | − { | |
| 143 | − id.write_hex(&mut buf) | |
| 144 | − .expect("no failure as everything is preset by now"); | |
| 145 | − } | |
| 130 | + let mut buf = [0u8; 40]; | |
| 131 | + hex::encode_to_slice(id, &mut buf).expect("no failure as everything is preset by now"); | |
| 132 | + let buf = std::str::from_utf8(&buf).expect("ascii only in hex"); | |
| 146 | 133 | root.push(&buf[..2]); |
| 147 | 134 | root.push(&buf[2..]); |
| 148 | 135 | root |