Avoid some copying
This commit is contained in:
parent
24afca5d32
commit
70a305458a
|
@ -820,7 +820,7 @@ pub fn decodestr<'de>(cow: Cow<'de, [u8]>) -> IOResult<Cow<'de, str>> {
|
|||
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<IOVal
|
|||
AtomMinor::SignedInteger => 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(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue