mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-14 19:55:03 +01:00
benchmark and improve method parsing
This commit is contained in:
parent
186f744715
commit
45196c722c
10 changed files with 593 additions and 210 deletions
|
|
@ -56,7 +56,7 @@ pub type IResult<'a, T> = nom::IResult<&'a [u8], T, TransError>;
|
|||
.join(", ");
|
||||
let class_name_raw = &class.name;
|
||||
println!(
|
||||
r#" let (input, _) = tag({class_index}_u16.to_be_bytes())(input).map_err(fail_err("invalid tag for class {class_name_raw}"))?;
|
||||
r#" let (input, _) = tag({class_index}_u16.to_be_bytes())(input)?;
|
||||
alt(({all_methods}))(input).map_err(fail_err("class {class_name_raw}"))"#
|
||||
);
|
||||
});
|
||||
|
|
@ -96,9 +96,7 @@ fn method_parser(amqp: &Amqp, class: &Class, method: &Method) {
|
|||
let function_name = method_function_name(&class_name)(method);
|
||||
function(&function_name, "Method", || {
|
||||
let method_index = method.index;
|
||||
println!(
|
||||
r#" let (input, _) = tag({method_index}_u16.to_be_bytes())(input).map_err(fail_err("parsing method index"))?;"#
|
||||
);
|
||||
println!(r#" let (input, _) = tag({method_index}_u16.to_be_bytes())(input)?;"#);
|
||||
let mut iter = method.fields.iter().peekable();
|
||||
while let Some(field) = iter.next() {
|
||||
let field_name_raw = &field.name;
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ use heck::ToUpperCamelCase;
|
|||
|
||||
pub(super) fn codegen_random(amqp: &Amqp) {
|
||||
println!(
|
||||
"#[cfg(test)]
|
||||
"
|
||||
mod random {{
|
||||
use rand::Rng;
|
||||
use crate::methods::tests::RandomMethod;
|
||||
use crate::methods::RandomMethod;
|
||||
use super::*;
|
||||
"
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue