[llvm] r242179 - Add support for on-disk hash table lookup with a known hash, for situations where the same key will be looked up in multiple tables.
David Blaikie
dblaikie at gmail.com
Tue Jul 14 13:32:30 PDT 2015
On Tue, Jul 14, 2015 at 11:40 AM, Richard Smith <richard-llvm at metafoo.co.uk>
wrote:
> Author: rsmith
> Date: Tue Jul 14 13:40:59 2015
> New Revision: 242179
>
> URL: http://llvm.org/viewvc/llvm-project?rev=242179&view=rev
> Log:
> Add support for on-disk hash table lookup with a known hash, for
> situations where the same key will be looked up in multiple tables.
>
> Modified:
> llvm/trunk/include/llvm/Support/OnDiskHashTable.h
>
> Modified: llvm/trunk/include/llvm/Support/OnDiskHashTable.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/OnDiskHashTable.h?rev=242179&r1=242178&r2=242179&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Support/OnDiskHashTable.h (original)
> +++ llvm/trunk/include/llvm/Support/OnDiskHashTable.h Tue Jul 14 13:40:59
> 2015
> @@ -280,13 +280,19 @@ public:
> };
>
> /// \brief Look up the stored data for a particular key.
> - iterator find(const external_key_type &EKey, Info *InfoPtr = 0) {
> - if (!InfoPtr)
> - InfoPtr = &InfoObj;
> -
> - using namespace llvm::support;
> + iterator find(const external_key_type &EKey, Info *InfoPtr = nullptr) {
> const internal_key_type &IKey = InfoObj.GetInternalKey(EKey);
> hash_value_type KeyHash = InfoObj.ComputeHash(IKey);
> + return find_hashed(IKey, KeyHash, InfoPtr);
> + }
> +
> + /// \brief Look up the stored data for a particular key with a known
> hash.
> + iterator find_hashed(const internal_key_type &IKey, hash_value_type
> KeyHash,
> + Info *InfoPtr = nullptr) {
>
Could/should this be generalized something like DenseMap's find_as instead?
(perhaps with a hash+value tuple convenience/special case) I suppose it
wouldn't make the API any easier for your use case, though - so can
probably wait until someone has a need for such a thing.
> + using namespace llvm::support;
> +
> + if (!InfoPtr)
> + InfoPtr = &InfoObj;
>
> // Each bucket is just an offset into the hash table file.
> offset_type Idx = KeyHash & (NumBuckets - 1);
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150714/57d118f5/attachment.html>
More information about the llvm-commits
mailing list