[PATCH] cache-tree: use ce_namelen() instead of strlen()
- From
René Scharfe <l.s.r@web.de>
- Date
- Jan 2, 2021, 15:19 UTC
- Message-ID
- <a8b5bb13-5c88-d744-b47e-7204e12ad05d@web.de>
- In-Reply-To
- <3ed37ae6-1f09-bd6b-c9d9-c8089da1af92@gmail.com>
Use the name length field of cache entries instead of calculating its value anew.
Signed-off-by: René Scharfe <l.s.r@web.de> --- Not sure why it took me so long to spot this.. o_O
cache-tree.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/cache-tree.c b/cache-tree.c index a537a806c1..57cacab195 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -185,10 +185,12 @@ static int verify_cache(struct cache_entry **cache, * the cache is sorted. Also path can appear only once, * which means conflicting one would immediately follow. */ - const char *this_name = cache[i]->name; - const char *next_name = cache[i+1]->name; - int this_len = strlen(this_name); - if (this_len < strlen(next_name) && + const struct cache_entry *this_ce = cache[i]; + const struct cache_entry *next_ce = cache[i + 1]; + const char *this_name = this_ce->name; + const char *next_name = next_ce->name; + int this_len = ce_namelen(this_ce); + if (this_len < ce_namelen(next_ce) && strncmp(this_name, next_name, this_len) == 0 && next_name[this_len] == '/') { if (10 < ++funny) { -- 2.30.0