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

lint naive counts #1446

Closed
llogiq opened this issue Jan 16, 2017 · 3 comments
Closed

lint naive counts #1446

llogiq opened this issue Jan 16, 2017 · 3 comments

Comments

@llogiq
Copy link
Contributor

llogiq commented Jan 16, 2017

Lint _.iter().filter(predicate).count(), suggest _.iter().map(|x| predicate(x) as usize).sum(), which results in branchless code that is usually faster.

@mcarton
Copy link
Member

mcarton commented Jan 16, 2017

Meh, the semantic of filter().count() is clearer, if .map(as usize).sum() really is more efficient, this is to be fixed in rustc.

@llogiq
Copy link
Contributor Author

llogiq commented Jan 16, 2017

I agree. Leaving this open until fixed.

@llogiq
Copy link
Contributor Author

llogiq commented Jan 16, 2017

Closing in favor of rust-lang/rust#39107

@llogiq llogiq closed this as completed Jan 16, 2017
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

No branches or pull requests

2 participants