1
0
Fork 0
forked from wry/wry

wayland: optimize parsing of fixed-size messages

This commit is contained in:
Julian Orth 2026-03-28 22:07:41 +01:00
parent b745e20f7f
commit 755bfdd661
6 changed files with 92 additions and 25 deletions

View file

@ -235,6 +235,7 @@ pub struct Message {
pub fields: Vec<Lined<Field>>,
pub attribs: MessageAttribs,
pub has_reference_type: bool,
pub is_fixed_size: bool,
}
#[derive(Debug, Default)]
@ -344,6 +345,11 @@ impl<'a> Parser<'a> {
Type::OptStr | Type::Str | Type::BStr | Type::Array(..) => true,
_ => false,
});
let is_variable_size = fields.iter().any(|f| match &f.val.ty.val {
Type::OptStr | Type::Str | Type::BStr | Type::Array(..) | Type::Pod(..) => true,
_ => false,
});
let is_fixed_size = !is_variable_size;
let safe_name = match name {
"move" => "move_",
"type" => "type_",
@ -361,6 +367,7 @@ impl<'a> Parser<'a> {
fields,
attribs,
has_reference_type,
is_fixed_size,
},
})
})();