mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-09 10:14:21 +01:00
core: Skip UTF-8 validation in read_value()
The UTF-8 validation is very expensive. It's unclear if we ever need to do it at read time and if we do, let's do it when we know the value is actually going to be used. Speeds up read_value() a lot.
This commit is contained in:
@@ -401,7 +401,8 @@ pub fn read_value(buf: &[u8], serial_type: &SerialType) -> Result<(Value, usize)
|
||||
if buf.len() < n {
|
||||
return Err(anyhow!("Invalid String value"));
|
||||
}
|
||||
let value = String::from_utf8(buf[0..n].to_vec())?;
|
||||
let bytes = buf[0..n].to_vec();
|
||||
let value = unsafe { String::from_utf8_unchecked(bytes) };
|
||||
Ok((Value::Text(value), n))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user