Avoid generating empty closures for fieldless enums
For many enums, this avoids generating lots of tiny stubs that need to be codegen'd and then inlined and removed by LLVM.
This commit is contained in:
@@ -589,6 +589,13 @@ impl<'a> crate::Encoder for Encoder<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn emit_fieldless_enum_variant<const ID: usize>(
|
||||
&mut self,
|
||||
name: &str,
|
||||
) -> Result<(), Self::Error> {
|
||||
escape_str(self.writer, name)
|
||||
}
|
||||
|
||||
fn emit_enum_variant_arg<F>(&mut self, first: bool, f: F) -> EncodeResult
|
||||
where
|
||||
F: FnOnce(&mut Encoder<'a>) -> EncodeResult,
|
||||
@@ -885,6 +892,13 @@ impl<'a> crate::Encoder for PrettyEncoder<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn emit_fieldless_enum_variant<const ID: usize>(
|
||||
&mut self,
|
||||
name: &str,
|
||||
) -> Result<(), Self::Error> {
|
||||
escape_str(self.writer, name)
|
||||
}
|
||||
|
||||
fn emit_enum_variant_arg<F>(&mut self, first: bool, f: F) -> EncodeResult
|
||||
where
|
||||
F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult,
|
||||
|
||||
Reference in New Issue
Block a user