mirror of https://github.com/fafhrd91/actix-net
perf(bytestring): improve `From<ByteString> for String` performance (#852)
This commit is contained in:
parent
cf12822c8d
commit
704bee0d84
|
|
@ -3,6 +3,7 @@
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
- Minimum supported Rust version (MSRV) is now 1.88.
|
- Minimum supported Rust version (MSRV) is now 1.88.
|
||||||
|
- Improve `From<ByteString> for String` performance.
|
||||||
|
|
||||||
## 1.5.0
|
## 1.5.0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,7 @@
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
use alloc::{
|
use alloc::{boxed::Box, string::String, vec::Vec};
|
||||||
boxed::Box,
|
|
||||||
string::{String, ToString},
|
|
||||||
vec::Vec,
|
|
||||||
};
|
|
||||||
use core::{borrow::Borrow, fmt, hash, ops, str};
|
use core::{borrow::Borrow, fmt, hash, ops, str};
|
||||||
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
|
|
@ -189,7 +185,7 @@ impl From<Box<str>> for ByteString {
|
||||||
impl From<ByteString> for String {
|
impl From<ByteString> for String {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(value: ByteString) -> Self {
|
fn from(value: ByteString) -> Self {
|
||||||
value.to_string()
|
String::from_utf8(value.0.into()).expect("ByteString invariant violated")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue