Skip to content

Commit 0b72536

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4bdde33 commit 0b72536

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

cache-tree.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,12 @@ static int verify_cache(struct cache_entry **cache,
185185
* the cache is sorted. Also path can appear only once,
186186
* which means conflicting one would immediately follow.
187187
*/
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) &&
192194
strncmp(this_name, next_name, this_len) == 0 &&
193195
next_name[this_len] == '/') {
194196
if (10 < ++funny) {

0 commit comments

Comments
 (0)