-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Adding benchmarks for macro rules in match statements #23
Conversation
macros/benches/match.rs
Outdated
} | ||
|
||
macro_rules! gen_match { | ||
($TinyType:ident, [$( ($item:ident, $tiny:expr) ),*]) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Manishearth @zbraniecki @filmil Is there a macro_rules!
definition here where I can call the sub-macro like tinystr4!
instead of repeating the strings, once as an identifier and once as a TinyStr? In other words, at the call site, instead of
gen_match!(TinyStr4, [
(US, tinystr4!("US")),
(GB, tinystr4!("GB")),
(AR, tinystr4!("AR"))
]);
how can I make it
gen_match!(TinyStr4, tinystr4!, [
US,
GB,
AR
]);
I rebased this branch against master. The results still show a substantial speed improvement for matching on TinyStr instead of &str:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! Thank you!
Microbenchmarks for #22
To run these benchmarks:
$ cd macros $ cargo +nightly bench