diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-09-17 13:53:57 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-09-17 13:53:57 -0700 |
commit | 769af0fd9ea0b4de172b51ae4b9ea41b57c02fd3 (patch) | |
tree | 524c7d9759fb9deae7b82581aa28fc8bc38265f6 /packfile.c | |
parent | d88949d86eddb62acbc85c16c97587db043d05b1 (diff) | |
parent | d9f62dfa0ddc31bdad93054acca9fd42ca781f7f (diff) | |
download | git-769af0fd9ea0b4de172b51ae4b9ea41b57c02fd3.tar.gz |
Merge branch 'jk/cocci'
spatch transformation to replace boolean uses of !hashcmp() to
newly introduced oideq() is added, and applied, to regain
performance lost due to support of multiple hash algorithms.
* jk/cocci:
show_dirstat: simplify same-content check
read-cache: use oideq() in ce_compare functions
convert hashmap comparison functions to oideq()
convert "hashcmp() != 0" to "!hasheq()"
convert "oidcmp() != 0" to "!oideq()"
convert "hashcmp() == 0" to hasheq()
convert "oidcmp() == 0" to oideq()
introduce hasheq() and oideq()
coccinelle: use <...> for function exclusion
Diffstat (limited to 'packfile.c')
-rw-r--r-- | packfile.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/packfile.c b/packfile.c index cbef7033c3..841b36182f 100644 --- a/packfile.c +++ b/packfile.c @@ -550,7 +550,7 @@ static int open_packed_git_1(struct packed_git *p) if (read_result != hashsz) return error("packfile %s signature is unavailable", p->pack_name); idx_hash = ((unsigned char *)p->index_data) + p->index_size - hashsz * 2; - if (hashcmp(hash, idx_hash)) + if (!hasheq(hash, idx_hash)) return error("packfile %s does not match index", p->pack_name); return 0; } @@ -1122,7 +1122,7 @@ void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1) { unsigned i; for (i = 0; i < p->num_bad_objects; i++) - if (!hashcmp(sha1, p->bad_object_sha1 + GIT_SHA1_RAWSZ * i)) + if (hasheq(sha1, p->bad_object_sha1 + GIT_SHA1_RAWSZ * i)) return; p->bad_object_sha1 = xrealloc(p->bad_object_sha1, st_mult(GIT_MAX_RAWSZ, @@ -1138,8 +1138,8 @@ const struct packed_git *has_packed_and_bad(const unsigned char *sha1) for (p = the_repository->objects->packed_git; p; p = p->next) for (i = 0; i < p->num_bad_objects; i++) - if (!hashcmp(sha1, - p->bad_object_sha1 + the_hash_algo->rawsz * i)) + if (hasheq(sha1, + p->bad_object_sha1 + the_hash_algo->rawsz * i)) return p; return NULL; } @@ -1937,8 +1937,8 @@ static int fill_pack_entry(const struct object_id *oid, if (p->num_bad_objects) { unsigned i; for (i = 0; i < p->num_bad_objects; i++) - if (!hashcmp(oid->hash, - p->bad_object_sha1 + the_hash_algo->rawsz * i)) + if (hasheq(oid->hash, + p->bad_object_sha1 + the_hash_algo->rawsz * i)) return 0; } |