Skip to content

Way to precompute a hash for searches? #156

@TomArrow

Description

@TomArrow

Is your feature request related to a problem? Please describe.
I have a map that is parsed from a string that contains a few dozen key->value pairs. The data isn't fixed, so some keys may be there, or may not. However the keys I'm interested in are always the same, I just use string literals for them. Computing a fresh hash on every lookup feels expensive. Would be nice to have a way to do something like
set.find(precomputed_hash,key)
and
map.find(precomputed_hash,key)

Describe the solution you'd like
Ideally something that's syntactically nice, but I'd be happy to be able to just have a precomputed const hash at startup and use it for the lookup. Maybe the integrated ankerl std::string hash could be made constexpr as well? But that's not so important.

Describe alternatives you've considered
Idk

Additional context

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions