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

ustring hashing improvements #3577

Merged
merged 4 commits into from
Oct 12, 2022

Conversation

lgritz
Copy link
Collaborator

@lgritz lgritz commented Oct 3, 2022

I realized that the recently added ustringhash class is confusingly similar to the (obscure, barely used, mostly forgotten) ustringHash functor. But also ustringHash doesn't need to exist, because it's equivalent to std::hash<ustring>, if we define it. So now we do define it, and also std::hash<ustringhash>, and deprecate ustringHash, to be removed entirely for 3.0.

Also, add a ustring ctr from ustringhash (explicit only for now), and operator< for ustringhash.

Finally, modernize a few places we still used (void) to just ().

@lgritz lgritz force-pushed the lg-ustringhasher branch 3 times, most recently from 4042051 to 9b3a99e Compare October 7, 2022 00:22
lgritz added 2 commits October 9, 2022 09:00
I realized that the recently added ustringhash class is confusingly
similar to the (obscure, barely used, mostly forgotten) ustringHash
functor. But also ustringHash doesn't need to exist, because it's
equivalent to `std::hash<ustring>`, if we define it. So now we do define
it, and also `std::hash<ustringhash>`, and deprecate ustringHash, to
be removed entirely for 3.0.

Also, add a ustring ctr from ustringhash (explicit only for now),
and `operator<` for ustringhash.

And add from_hash(size_t) method to ustringhash, analogous to
ustring::from_hash().

Finally, modernize a few places we still used `(void)` to just `()`.
rep_t is the type of the underlying representation (const char* for
ustring, size_t for ustringhash).

Modernize some typedef into using.
Copy link
Collaborator

@AlexMWells AlexMWells left a comment

Choose a reason for hiding this comment

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

LGTM.
btw: I see the ustringhash constructor can't be constexpr because it constructs a ustring which is surely cannot be constexpr.

@lgritz lgritz merged commit bbd48ca into AcademySoftwareFoundation:master Oct 12, 2022
lgritz added a commit to lgritz/OpenImageIO that referenced this pull request Oct 12, 2022
I realized that the recently added ustringhash class is confusingly
similar to the (obscure, barely used, mostly forgotten) ustringHash
functor. But also ustringHash doesn't need to exist, because it's
equivalent to `std::hash<ustring>`, if we define it. So now we do define
it, and also `std::hash<ustringhash>`, and deprecate ustringHash, to
be removed entirely for 3.0.

Also, add a ustring ctr from ustringhash (explicit only for now),
and `operator<` for ustringhash.

And add from_hash(size_t) method to ustringhash, analogous to
ustring::from_hash().

Modernize a few places we still used `(void)` to just `()`.

Give ustring and ustringhash a `using rep_t =`
rep_t is the type of the underlying representation (const char* for
ustring, size_t for ustringhash).

Modernize some typedef into using.

Make `==` and `!=(ustringhash, const char*)` be constexpr for C++ >= 17
@lgritz lgritz deleted the lg-ustringhasher branch October 15, 2022 04:46
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