mirror of https://github.com/mpv-player/mpv
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:
parent
fee6b287a5
commit
779031ad8f
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue