From 5250c229315dab9a6dbf68385dae88f561b0fbe1 Mon Sep 17 00:00:00 2001 From: наб Date: Thu, 14 Nov 2024 17:36:43 +0100 Subject: Move StringViewCompareFast to strutil.h --- apt-pkg/contrib/string_view.h | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'apt-pkg/contrib/string_view.h') diff --git a/apt-pkg/contrib/string_view.h b/apt-pkg/contrib/string_view.h index b062517b6..34a8e8a95 100644 --- a/apt-pkg/contrib/string_view.h +++ b/apt-pkg/contrib/string_view.h @@ -146,17 +146,6 @@ inline std::ostream& operator<<(std::ostream& os, const StringView& sv) return os << static_cast(sv); } -/** - * \brief Faster comparison for string views (compare size before data) - * - * Still stable, but faster than the normal ordering. */ -static inline int StringViewCompareFast(const std::string_view & a, const std::string_view & b) { - if (a.size() != b.size()) - return a.size() - b.size(); - - return a.compare(b); -} - static constexpr inline APT::StringView operator""_sv(const char *data, size_t size) { return APT::StringView(data, size); -- cgit v1.2.3-70-g09d2 From 0cc32385f109705aac51e354d854833d6203f773 Mon Sep 17 00:00:00 2001 From: наб Date: Thu, 14 Nov 2024 17:40:13 +0100 Subject: if APT_PKG_ABI > 600: using APT::StringView = std::string_view; --- apt-pkg/contrib/string_view.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'apt-pkg/contrib/string_view.h') diff --git a/apt-pkg/contrib/string_view.h b/apt-pkg/contrib/string_view.h index 34a8e8a95..6224e2ac4 100644 --- a/apt-pkg/contrib/string_view.h +++ b/apt-pkg/contrib/string_view.h @@ -15,6 +15,11 @@ #include #include +#if APT_PKG_ABI > 600 +namespace APT { +using StringView = std::string_view; +} +#else namespace APT { /** @@ -157,5 +162,6 @@ inline bool operator ==(const char *other, APT::StringView that) { return that.o template bool operator ==(std::string_view const &other, APT::StringView const &that) { return that.operator==(other); } template bool operator !=(std::string_view const &other, APT::StringView const &that) { return that.operator!=(other); } template bool operator !=(APT::StringView const &that, std::string_view const &other) { return that.operator!=(other); } +#endif #endif -- cgit v1.2.3-70-g09d2