cache-tree: use ce_namelen() instead of strlen()
Use the name length field of cache entries instead of calculating its value anew. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Jan 7, 2021 at 16:32 UTC
0b72536a0b6128d2bfd05d633cd2228d7515b53d
1 file changed
+6
-4
cache-tree.c
+6
-4
@@ -185,10 +185,12 @@ static int verify_cache(struct cache_entry **cache,
185
* the cache is sorted. Also path can appear only once,
186
* which means conflicting one would immediately follow.
187
*/
188
- const char *this_name = cache[i]->name;
189
- const char *next_name = cache[i+1]->name;
190
- int this_len = strlen(this_name);
191
- if (this_len < strlen(next_name) &&
188
+ const struct cache_entry *this_ce = cache[i];
189
+ const struct cache_entry *next_ce = cache[i + 1];
190
+ const char *this_name = this_ce->name;
191
+ const char *next_name = next_ce->name;
192
+ int this_len = ce_namelen(this_ce);
193
+ if (this_len < ce_namelen(next_ce) &&
194
strncmp(this_name, next_name, this_len) == 0 &&
195
next_name[this_len] == '/') {
196
if (10 < ++funny) {