-
Notifications
You must be signed in to change notification settings - Fork 84
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
Abstract key lookup into a trait for Family::get_or_create #157
Comments
@mxinden, could you take a look? I'd like to implement it If it sounds reasonable |
Thank you for the code snippets. Generally I am not opposed to moving to Are you trying to optimize performance? If so, would you mind providing data on how much the above would safe you? Are you trying to optimize ergonomics? If so, I don't think having to implement |
I have huge label sets (10+ items) and can't formalize them in static types, it's just Strings in general. I have &str slices during data processing and copying them to locate the counter doesn't look good. I've added some bench in PR:
|
Perhaps using `Cowˋ would be useful? |
Family::get_or_create forces to clone labels data for the lookup of a counter. Example:
I must create RequestLabels with cloning host and api values instead of getting counter by data references. The Family struct uses the std::collections::HashMap inside, which doesn't allow any other way to look up.
It would be great to have the ability to write something like this:
This will require using hashbrown instead of std::collections::HashMap (but actually std map is wrapper on hashbrown).
Equivalent
HashMap::get
Also, it will affect the definition of Family::get_or_create but the behavior should be the same.
The text was updated successfully, but these errors were encountered: