Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add hash() and get_index() to phf_shared.
In https://github.com/servo/string-cache, we currently use a `phf::OrderedSet` with its `get_index` method to get an identified stored in an `Atom`, and `index` to get a string back from that identifier. However, the extra inderection of `OrderedSet` of `Set` is not necessary. We don’t care about the order, only about getting numeric identifiers. Additionally, when `get_index` returns `None`, we hash the input string again to find it in table of dynamic atoms. With this chang, we can reuse the phf hash instead: servo/string-cache#103 At first I tried adding hash and index access to `phf::Map`, but the API got messy quickly.
- Loading branch information
1 parent
96ef156
commit d3b2ea0
Showing
4 changed files
with
29 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters