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
This commit is contained in:
Junio C Hamano
2018-09-17 13:53:57 -07:00
75 changed files with 258 additions and 223 deletions

View File

@ -573,7 +573,7 @@ static struct object_entry *find_object(struct object_id *oid)
unsigned int h = oid->hash[0] << 8 | oid->hash[1];
struct object_entry *e;
for (e = object_table[h]; e; e = e->next)
if (!oidcmp(oid, &e->idx.oid))
if (oideq(oid, &e->idx.oid))
return e;
return NULL;
}
@ -584,7 +584,7 @@ static struct object_entry *insert_object(struct object_id *oid)
struct object_entry *e = object_table[h];
while (e) {
if (!oidcmp(oid, &e->idx.oid))
if (oideq(oid, &e->idx.oid))
return e;
e = e->next;
}
@ -1534,7 +1534,7 @@ static int tree_content_set(
if (!*slash1) {
if (!S_ISDIR(mode)
&& e->versions[1].mode == mode
&& !oidcmp(&e->versions[1].oid, oid))
&& oideq(&e->versions[1].oid, oid))
return 0;
e->versions[1].mode = mode;
oidcpy(&e->versions[1].oid, oid);
@ -2650,7 +2650,7 @@ static int parse_from(struct branch *b)
struct object_entry *oe = find_mark(idnum);
if (oe->type != OBJ_COMMIT)
die("Mark :%" PRIuMAX " not a commit", idnum);
if (oidcmp(&b->oid, &oe->idx.oid)) {
if (!oideq(&b->oid, &oe->idx.oid)) {
oidcpy(&b->oid, &oe->idx.oid);
if (oe->pack_id != MAX_PACK_ID) {
unsigned long size;
@ -2668,7 +2668,7 @@ static int parse_from(struct branch *b)
else
die("Invalid ref name or SHA1 expression: %s", from);
if (b->branch_tree.tree && oidcmp(&oid, &b->branch_tree.versions[1].oid)) {
if (b->branch_tree.tree && !oideq(&oid, &b->branch_tree.versions[1].oid)) {
release_tree_content_recursive(b->branch_tree.tree);
b->branch_tree.tree = NULL;
}