bstr: short-circuit bstr_equals on pointer equality

More efficient in cases where we're comparing a bstr against itself,
which can happen in e.g. the ICC profile code.
This commit is contained in:
Niklas Haas 2017-07-27 00:09:00 +02:00
parent fee6b287a5
commit 779031ad8f
1 changed files with 4 additions and 1 deletions

View File

@ -193,7 +193,10 @@ static inline int bstrcmp0(struct bstr str1, const char *str2)
static inline bool bstr_equals(struct bstr str1, struct bstr str2)
{
return str1.len == str2.len && bstrcmp(str1, str2) == 0;
if (str1.len != str2.len)
return false;
return str1.start == str2.start || bstrcmp(str1, str2) == 0;
}
static inline bool bstr_equals0(struct bstr str1, const char *str2)