提交 18f5f996 编写于 作者: O Oliver Middleton

Slightly optimise CString

Avoid a reallocation in CString::from and CStr::to_owned.
上级 acfe9597
......@@ -686,7 +686,7 @@ impl ToOwned for CStr {
type Owned = CString;
fn to_owned(&self) -> CString {
unsafe { CString::from_vec_unchecked(self.to_bytes().to_vec()) }
CString { inner: self.to_bytes_with_nul().to_vec().into_boxed_slice() }
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册