We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents fa2f83c + c971ddf commit f12e49aCopy full SHA for f12e49a
refs.c
@@ -333,14 +333,12 @@ struct string_slice {
333
334
static int ref_entry_cmp_sslice(const void *key_, const void *ent_)
335
{
336
- struct string_slice *key = (struct string_slice *)key_;
337
- struct ref_entry *ent = *(struct ref_entry **)ent_;
338
- int entlen = strlen(ent->name);
339
- int cmplen = key->len < entlen ? key->len : entlen;
340
- int cmp = memcmp(key->str, ent->name, cmplen);
+ const struct string_slice *key = key_;
+ const struct ref_entry *ent = *(const struct ref_entry * const *)ent_;
+ int cmp = strncmp(key->str, ent->name, key->len);
341
if (cmp)
342
return cmp;
343
- return key->len - entlen;
+ return '\0' - (unsigned char)ent->name[key->len];
344
}
345
346
/*
0 commit comments