use fspathhash() everywhere

cf2dc1c238 (speed up alt_odb_usable() with many alternates, 2021-07-07)
introduced the function fspathhash() for calculating path hashes while
respecting the configuration option core.ignorecase.  Call it instead of
open-coding it; the resulting code is shorter and less repetitive.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe
2021-07-30 21:06:58 +02:00
committed by Junio C Hamano
parent 940fe202ad
commit 7431842325
3 changed files with 8 additions and 26 deletions

13
dir.c
View File

@ -782,9 +782,7 @@ static void add_pattern_to_hashsets(struct pattern_list *pl, struct path_pattern
translated->pattern = truncated;
translated->patternlen = given->patternlen - 2;
hashmap_entry_init(&translated->ent,
ignore_case ?
strihash(translated->pattern) :
strhash(translated->pattern));
fspathhash(translated->pattern));
if (!hashmap_get_entry(&pl->recursive_hashmap,
translated, ent, NULL)) {
@ -813,9 +811,7 @@ static void add_pattern_to_hashsets(struct pattern_list *pl, struct path_pattern
translated->pattern = dup_and_filter_pattern(given->pattern);
translated->patternlen = given->patternlen;
hashmap_entry_init(&translated->ent,
ignore_case ?
strihash(translated->pattern) :
strhash(translated->pattern));
fspathhash(translated->pattern));
hashmap_add(&pl->recursive_hashmap, &translated->ent);
@ -845,10 +841,7 @@ static int hashmap_contains_path(struct hashmap *map,
/* Check straight mapping */
p.pattern = pattern->buf;
p.patternlen = pattern->len;
hashmap_entry_init(&p.ent,
ignore_case ?
strihash(p.pattern) :
strhash(p.pattern));
hashmap_entry_init(&p.ent, fspathhash(p.pattern));
return !!hashmap_get_entry(map, &p, ent, NULL);
}