Skip to content

Commit

Permalink
serde optimization for StringData chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
TimLuq committed Jul 5, 2024
1 parent 0ac6dd9 commit ff0c132
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/serde_1/stringdata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ impl<'de> serde::de::Deserialize<'de> for StringData<'de> {
}

fn visit_str<E: serde::de::Error>(self, _v: &str) -> Result<Self::Value, E> {
#[cfg(feature = "chunk")]
if _v.len() <= 12 {
return Ok(unsafe { StringData::from_bytedata_unchecked(crate::ByteData::from_chunk_slice(_v.as_bytes())) });
}
#[cfg(feature = "alloc")]
{
Ok(StringData::from_borrowed(_v).into_shared())
Expand Down

0 comments on commit ff0c132

Please sign in to comment.