Reduce instantiations of Result::map in Deserialize of unit variants

This eliminates 110 instantiations of Result::map in Xi and reduces
binary size by 229 kilobytes.
This commit is contained in:
David Tolnay 2018-04-21 13:25:24 -07:00
parent 1a972d2105
commit df93fab5fa
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -1626,12 +1626,13 @@ fn deserialize_untagged_variant(
let type_name = params.type_name();
let variant_name = variant.ident.as_ref();
quote_expr! {
_serde::export::Result::map(
_serde::Deserializer::deserialize_any(
match _serde::Deserializer::deserialize_any(
#deserializer,
_serde::private::de::UntaggedUnitVisitor::new(#type_name, #variant_name)
),
|()| #this::#variant_ident)
) {
_serde::export::Ok(()) => _serde::export::Ok(#this::#variant_ident),
_serde::export::Err(__err) => _serde::export::Err(__err),
}
}
}
Style::Newtype => deserialize_untagged_newtype_variant(