Avoid a few heap allocations that aren't strictly needed

This commit is contained in:
Deirdre Connolly 2020-02-12 18:54:05 -05:00 committed by Deirdre Connolly
parent 2468acb9db
commit 54b1172dc8
1 changed files with 2 additions and 2 deletions

View File

@ -48,8 +48,8 @@ impl fmt::Debug for Memo {
// This saves work but if the 'valid utf8 string' is just a
// bunch of numbers, it prints them out like
// 'Memo("\u{0}\u{0}..")', so. ¯\_(ツ)_/¯
match String::from_utf8(self.0.to_vec()) {
Ok(memo) => output = memo,
match std::str::from_utf8(&self.0[..]) {
Ok(memo) => output = String::from(memo),
_ => output = hex::encode(&self.0[..]),
}