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

Don't allocate a vec for repeat count if it's not used #292

Closed

Conversation

coolreader18
Copy link

No description provided.

@kevinmehall
Copy link
Owner

I think we might already be getting the optimization you're trying to make here. If result_used == false is passed to the inner expression, its return type will be () and Rust is smart enough to not actually allocate for that -- Vec<()> is just a counter.

Is there an example where you've confirmed that it's actually allocating and doesn't need to?

@coolreader18
Copy link
Author

Ohhh, I think I missed that; you're right. That's clever, generic programming ftw I suppose.

@coolreader18 coolreader18 deleted the repeat-count-no-vec branch March 30, 2022 05:34
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