diff options
| author | Julian Andres Klode <jak@debian.org> | 2024-11-14 18:39:54 +0000 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2024-11-14 18:39:54 +0000 |
| commit | f7fb7fb921c3bbfa0ef086b0cc9343d126d0ed09 (patch) | |
| tree | df2a0c967969fe7d899ba9a00af83d776f563cb0 /apt-pkg/contrib/string_view.h | |
| parent | caf668388f2be7546989c97ab19ec4caeda73c92 (diff) | |
| parent | 0cc32385f109705aac51e354d854833d6203f773 (diff) | |
Merge branch 'svequiv3everything' into 'main'
Prepare for APT::StringView -> std::string_view, #if APT_PKG_ABI > 600: ABI migrations and using APT::StringView = std::string_view;
See merge request apt-team/apt!396
Diffstat (limited to 'apt-pkg/contrib/string_view.h')
| -rw-r--r-- | apt-pkg/contrib/string_view.h | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/apt-pkg/contrib/string_view.h b/apt-pkg/contrib/string_view.h index b062517b6..6224e2ac4 100644 --- a/apt-pkg/contrib/string_view.h +++ b/apt-pkg/contrib/string_view.h @@ -15,6 +15,11 @@ #include <cstring> #include <string> +#if APT_PKG_ABI > 600 +namespace APT { +using StringView = std::string_view; +} +#else namespace APT { /** @@ -146,17 +151,6 @@ inline std::ostream& operator<<(std::ostream& os, const StringView& sv) return os << static_cast<std::string_view>(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); @@ -168,5 +162,6 @@ inline bool operator ==(const char *other, APT::StringView that) { return that.o template<class = void> bool operator ==(std::string_view const &other, APT::StringView const &that) { return that.operator==(other); } template<class = void> bool operator !=(std::string_view const &other, APT::StringView const &that) { return that.operator!=(other); } template<class = void> bool operator !=(APT::StringView const &that, std::string_view const &other) { return that.operator!=(other); } +#endif #endif |
