Skip to content

Avoid repeated get_span in quote_spanned#329

Open
Noratrieb wants to merge 1 commit into
dtolnay:masterfrom
Noratrieb:avoid-repeat-expand
Open

Avoid repeated get_span in quote_spanned#329
Noratrieb wants to merge 1 commit into
dtolnay:masterfrom
Noratrieb:avoid-repeat-expand

Conversation

@Noratrieb

Copy link
Copy Markdown

Every group used in quote_spanned would cause a nested quote_spanned to be called for the contents of the group. This caused $crate::__private::get_span($span).__into_span() to be called every time, causing lots of unnecessary code.
By only doing this in the user-facing macro and just reusing the identifier for internal recursion we avoid this extra code.

This cuts the expanded lines of code from tracing-attributes by almost 300.

Every group used in `quote_spanned` would cause a nested `quote_spanned`
to be called for the contents of the group. This caused
`$crate::__private::get_span($span).__into_span()` to be called every
time, causing lots of unnecessary code.
By only doing this in the user-facing macro and just reusing the
identifier for internal recursion we avoid this extra code.

This cuts the expanded lines of code from `tracing-attributes` by almost
300.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant