summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-07-21 11:18:44 -0700
committerJunio C Hamano <gitster@pobox.com>2014-07-21 11:18:44 -0700
commit9b1c2a3a8e625ea7f56e9ba3d3c0e31938faa738 (patch)
treeaa21c9fad684c6f6e16d4a1c69a6c6bd70dd54c3 /builtin
parent0ac744305f5885207bf96fc5488fcc59782ffa96 (diff)
parent7b64d42d22206d9995a8f0cb3b515e623cac4702 (diff)
downloadgit-9b1c2a3a8e625ea7f56e9ba3d3c0e31938faa738.tar.gz
Merge branch 'kb/hashmap-updates'
* kb/hashmap-updates: hashmap: add string interning API hashmap: add simplified hashmap_get_from_hash() API hashmap: improve struct hashmap member documentation hashmap: factor out getting a hash code from a SHA1
Diffstat (limited to 'builtin')
-rw-r--r--builtin/describe.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/builtin/describe.c b/builtin/describe.c
index 24d740c8b1..ee6a3b998f 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -56,18 +56,9 @@ static int commit_name_cmp(const struct commit_name *cn1,
return hashcmp(cn1->peeled, peeled ? peeled : cn2->peeled);
}
-static inline unsigned int hash_sha1(const unsigned char *sha1)
-{
- unsigned int hash;
- memcpy(&hash, sha1, sizeof(hash));
- return hash;
-}
-
static inline struct commit_name *find_commit_name(const unsigned char *peeled)
{
- struct commit_name key;
- hashmap_entry_init(&key, hash_sha1(peeled));
- return hashmap_get(&names, &key, peeled);
+ return hashmap_get_from_hash(&names, sha1hash(peeled), peeled);
}
static int replace_name(struct commit_name *e,
@@ -114,7 +105,7 @@ static void add_to_known_names(const char *path,
if (!e) {
e = xmalloc(sizeof(struct commit_name));
hashcpy(e->peeled, peeled);
- hashmap_entry_init(e, hash_sha1(peeled));
+ hashmap_entry_init(e, sha1hash(peeled));
hashmap_add(&names, e);
e->path = NULL;
}