Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2023-05-16 09:34:07 +0300
committerJunio C Hamano <gitster@pobox.com>2023-06-21 23:39:54 +0300
commitb9a7ac2c6897efbf78fd546b21986498577e3585 (patch)
tree0d411dad1f60c27936b5b86d39ab88f2e2ac7d2b /hashmap.h
parenta034e9106ff1a4cb6fcb6f2ea3a1a47b4d2ba173 (diff)
hash-ll, hashmap: move oidhash() to hash-ll
oidhash() was used by both hashmap and khash, which makes sense. However, the location of this function in hashmap.[ch] meant that khash.h had to depend upon hashmap.h, making people unfamiliar with khash think that it was built upon hashmap. (Or at least, I personally was confused for a while about this in the past.) Move this function to hash-ll, so that khash.h can stop depending upon hashmap.h. This has another benefit as well: it allows us to remove hashmap.h's dependency on hash-ll.h. While some callers of hashmap.h were making use of oidhash, most were not, so this change provides another way to reduce the number of includes. Diff best viewed with `--color-moved`. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'hashmap.h')
-rw-r--r--hashmap.h21
1 files changed, 0 insertions, 21 deletions
diff --git a/hashmap.h b/hashmap.h
index 2695f3d3a6..c8216e47bb 100644
--- a/hashmap.h
+++ b/hashmap.h
@@ -1,8 +1,6 @@
#ifndef HASHMAP_H
#define HASHMAP_H
-#include "hash-ll.h"
-
/*
* Generic implementation of hash-based key-value mappings.
*
@@ -121,25 +119,6 @@ unsigned int memihash(const void *buf, size_t len);
unsigned int memihash_cont(unsigned int hash_seed, const void *buf, size_t len);
/*
- * Converts a cryptographic hash (e.g. SHA-1) into an int-sized hash code
- * for use in hash tables. Cryptographic hashes are supposed to have
- * uniform distribution, so in contrast to `memhash()`, this just copies
- * the first `sizeof(int)` bytes without shuffling any bits. Note that
- * the results will be different on big-endian and little-endian
- * platforms, so they should not be stored or transferred over the net.
- */
-static inline unsigned int oidhash(const struct object_id *oid)
-{
- /*
- * Equivalent to 'return *(unsigned int *)oid->hash;', but safe on
- * platforms that don't support unaligned reads.
- */
- unsigned int hash;
- memcpy(&hash, oid->hash, sizeof(hash));
- return hash;
-}
-
-/*
* struct hashmap_entry is an opaque structure representing an entry in the
* hash table.
* Ideally it should be followed by an int-sized member to prevent unused