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

Add some comments about how quote_each_token works. #211

Merged
merged 1 commit into from
Mar 25, 2022
Merged

Add some comments about how quote_each_token works. #211

merged 1 commit into from
Mar 25, 2022

Conversation

nnethercote
Copy link
Contributor

I didn't understand how this code worked until I used trace_macros on
an example and saw some expansions. This commit contains the comments I
wish had been present.

I didn't understand how this code worked until I used `trace_macros` on
an example and saw some expansions. This commit contains the comments I
wish had been present.
@nnethercote
Copy link
Contributor Author

I updated the comment about performance -- the tt muncher is quadratic, this implementation is linear, but this implementation has higher constant factors and so is slower for short inputs. (I did some microbenchmarking to determine this.)

Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is great.

Comment on lines +731 to +732
// The parentheses around the middle tt aren't necessary, but they make the
// macro definitions easier to read.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part isn't right. I don't know how we would correctly drop the first 3 and last 3 quote_token_with_context calls without bracketing the middle token to make it unable to collide with the padding token (@).

I'll fix this in a followup PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks!

@dtolnay dtolnay merged commit 927317c into dtolnay:master Mar 25, 2022
dtolnay added a commit that referenced this pull request Mar 25, 2022
@nnethercote nnethercote deleted the add-comments branch March 25, 2022 09:23
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.

2 participants