perf(mysql): guarantee no allocation if no columns are passed to Row::deserialize_with

This commit is contained in:
Ryan Leckey 2021-01-29 23:37:29 -08:00
parent 4cbdac6884
commit ad6d4b5740
No known key found for this signature in database
GPG Key ID: F8AA68C235AB08C9

View File

@ -12,6 +12,10 @@ pub(crate) struct Row {
impl<'de> Deserialize<'de, &'de [ColumnDefinition]> for Row {
fn deserialize_with(mut buf: Bytes, columns: &'de [ColumnDefinition]) -> Result<Self> {
if columns.is_empty() {
return Ok(Self { values: vec![] });
}
let mut values = Vec::with_capacity(columns.len());
for _ in columns {