From 70a305458aa9cf97c9ed7281f842ef158bdab8d9 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Wed, 17 Jun 2020 11:01:44 +0200 Subject: [PATCH] Avoid some copying --- implementations/rust/src/value/reader.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/implementations/rust/src/value/reader.rs b/implementations/rust/src/value/reader.rs index d30e5cd..b4b4735 100644 --- a/implementations/rust/src/value/reader.rs +++ b/implementations/rust/src/value/reader.rs @@ -820,7 +820,7 @@ pub fn decodestr<'de>(cow: Cow<'de, [u8]>) -> IOResult> { Cow::Borrowed(bs) => Ok(Cow::Borrowed(std::str::from_utf8(bs).map_err(|_| io_syntax_error("Invalid UTF-8"))?)), Cow::Owned(bs) => - Ok(Cow::Owned(std::str::from_utf8(&bs).map_err(|_| io_syntax_error("Invalid UTF-8"))?.to_owned())), + Ok(Cow::Owned(String::from_utf8(bs).map_err(|_| io_syntax_error("Invalid UTF-8"))?.to_owned())), } } @@ -829,7 +829,7 @@ pub fn decodebinary<'de>(minor: AtomMinor, bs: Cow<'de, [u8]>) -> IOResult Value::from(&BigInt::from_signed_bytes_be(&bs)).wrap(), AtomMinor::String => Value::String(decodestr(bs)?.into_owned()).wrap(), AtomMinor::ByteString => Value::ByteString(bs.into_owned()).wrap(), - AtomMinor::Symbol => Value::symbol(&decodestr(bs)?).wrap(), + AtomMinor::Symbol => Value::Symbol(decodestr(bs)?.into_owned()).wrap(), }) }