Skip to content

Add frequency count to extra::stat. #8281 #8320

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

Closed
wants to merge 1 commit into from

Conversation

mihneadb
Copy link
Contributor

@mihneadb mihneadb commented Aug 6, 2013

No description provided.

None => 1
}
};
map.insert(elem, to_insert);
Copy link
Member

Choose a reason for hiding this comment

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

I feel like from 362 to here could be map.insert_or_update_with(elem, 1, |_, count| *count += 1), but I'm not sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I felt this was more readable but I have no problem of changing it, let me know about a final decision :).

Copy link
Member

Choose a reason for hiding this comment

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

Using insert_or_update_with means that elem is only hashed once, so it will be approximately 2 times faster. You could write it as

do map.insert_or_update_with(elem, 1) |_, count| {
    *count += 1;
}

if you felt that was more readable.

@alexcrichton
Copy link
Member

@cmr should probably take a look at this (he was the one who opened the issue originally).

Also, would you mind rebasing into a single commit?

@mihneadb
Copy link
Contributor Author

mihneadb commented Aug 7, 2013

Sure, will do after there are no more changes to be made.

@mihneadb
Copy link
Contributor Author

mihneadb commented Aug 7, 2013

@alexcrichton indeed, Clone was not needed. Thanks!

@emberian
Copy link
Member

emberian commented Aug 7, 2013

Hi @mihneadb,

This looks good! Can you squash the commits now?

@mihneadb
Copy link
Contributor Author

mihneadb commented Aug 7, 2013

@cmr sure, done. :) Thanks!

bors added a commit that referenced this pull request Aug 7, 2013
@bors bors closed this Aug 7, 2013
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.

5 participants