diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2017-01-27 02:05:40 -0800 |
---|---|---|
committer | Sam Bingner <sam@bingner.com> | 2019-08-17 12:43:03 -1000 |
commit | aa376cf54fbf98b7f13f86c2d46e19d6c941876b (patch) | |
tree | 8e72ceb8cfc8202118ea162178a8f8b6b6c1a5e5 /apt-pkg | |
parent | 20bb4620bb0f94026f4902b6b466f6fd4a062572 (diff) |
Bug #807012 also involves package dependencies :/.
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/contrib/string_view.h | 12 | ||||
-rw-r--r-- | apt-pkg/contrib/strutl.h | 21 |
2 files changed, 21 insertions, 12 deletions
diff --git a/apt-pkg/contrib/string_view.h b/apt-pkg/contrib/string_view.h index 536744e32..1cca0c17c 100644 --- a/apt-pkg/contrib/string_view.h +++ b/apt-pkg/contrib/string_view.h @@ -112,18 +112,6 @@ public: constexpr size_t length() const { return size_; } }; -/** - * \brief Faster comparison for string views (compare size before data) - * - * Still stable, but faster than the normal ordering. */ -static inline int StringViewCompareFast(StringView a, StringView b) { - if (a.size() != b.size()) - return a.size() - b.size(); - - return memcmp(a.data(), b.data(), a.size()); -} - - } inline bool operator ==(const char *other, APT::StringView that); diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h index 9f74f8c2a..790fc061a 100644 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@ -157,6 +157,27 @@ static inline int isspace_ascii_inline(int const c) return (c >= 9 && c <= 13) || c == ' '; } +// StringViewCompareFast - awkward attempt to optimize cache generation /*{{{*/ +#ifdef APT_PKG_EXPOSE_STRING_VIEW +/** + * \brief Faster comparison for string views (compare size before data) + * + * Still stable, but faster than the normal ordering. + * As this is used for package comparison this *MUST* be case insensitive, + * as the alternative is to lower case all dependency fields which is slow. */ +static inline int StringViewCompareFast(APT::StringView a, APT::StringView b) { + if (a.size() != b.size()) + return a.size() - b.size(); + auto l(a.data()), r(b.data()); + for (auto e(a.size()), i(decltype(e)(0)); i != e; ++i) + if (tolower_ascii_inline(l[i]) != tolower_ascii_inline(r[i])) + return tolower_ascii(l[i]) < tolower_ascii(r[i]) ? -1 : 1; + return 0; +} +#endif + /*}}}*/ + + std::string StripEpoch(const std::string &VerStr); #define APT_MKSTRCMP(name,func) \ |