From 779031ad8f3b74035b8e64a2353a52557d7b8ece Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Thu, 27 Jul 2017 00:09:00 +0200 Subject: 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. --- misc/bstr.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/misc/bstr.h b/misc/bstr.h index 199f300ba1..d6e2fdc18e 100644 --- a/misc/bstr.h +++ b/misc/bstr.h @@ -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) -- cgit v1.2.3