Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redefine try macro to omit From::from error conversion #2281

merged 1 commit into from Sep 22, 2022


Copy link

@dtolnay dtolnay commented Sep 22, 2022

None of the error handling in serde needs the From::from error conversion performed implicitly by the ? operator or the standard library's try! macro. This PR adds a simplified macro that gives a 5.5% improvement in compile time compared to standard try!, and 9% improvement compared to ?. The same trick has already been in use by serde_derive since #1226.

check time rmeta size build time rlib size
standard library try! 2.15 sec 3,568 K 2.53 sec 6,943 K
? operator 2.23 sec 3,568 K 2.62 sec 7,137 K
this PR 2.03 sec 3,569 K 2.39 sec 6,829 K

build time is measured by time rustc --cfg 'feature="std"' serde/src/ --crate-type=lib, and check time is the same but with --emit=metadata.

@dtolnay dtolnay merged commit f0346ae into serde-rs:master Sep 22, 2022
21 checks passed
@dtolnay dtolnay deleted the try branch Sep 22, 2022
@serde-rs serde-rs locked and limited conversation to collaborators Sep 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

Successfully merging this pull request may close these issues.

None yet

1 participant