diff options
| author | Julian Andres Klode <jak@debian.org> | 2025-01-14 08:26:23 +0000 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2025-01-14 08:26:23 +0000 |
| commit | ce452d40f499fa56f6ddc15e8871b1262d4e1418 (patch) | |
| tree | cca88ab8b56520eec386921aa51906d7bdf4f385 /apt-pkg/pkgcache.cc | |
| parent | f9a59225c3b1e025ad93116773cc7825621809c8 (diff) | |
| parent | aa4c681f09f06359c0892329b9e39da77e4f9fda (diff) | |
Merge branch 'fix/cleanup' into 'main'
Drop unused and obsolete macros as well as documentation
See merge request apt-team/apt!428
Diffstat (limited to 'apt-pkg/pkgcache.cc')
| -rw-r--r-- | apt-pkg/pkgcache.cc | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index ffe30fa92..1f5f12885 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -32,6 +32,7 @@ #include <apt-pkg/version.h> #include <algorithm> +#include <array> #include <cstddef> #include <cstring> #include <sstream> @@ -244,7 +245,7 @@ uint32_t pkgCache::CacheHash() XXH3_64bits_update(state, reinterpret_cast<const unsigned char *>(PACKAGE_VERSION), - APT_ARRAY_SIZE(PACKAGE_VERSION)); + strlen(PACKAGE_VERSION)); XXH3_64bits_update(state, reinterpret_cast<const unsigned char *>(&header), @@ -340,24 +341,40 @@ const char *pkgCache::CompType(unsigned char Comp) /* */ const char *pkgCache::DepType(unsigned char Type) { - const char *Types[] = {"",_("Depends"),_("PreDepends"),_("Suggests"), - _("Recommends"),_("Conflicts"),_("Replaces"), - _("Obsoletes"),_("Breaks"), _("Enhances")}; - if (Type < sizeof(Types)/sizeof(*Types)) + std::array<char const *, 12> Types{nullptr, _("Depends"), _("PreDepends"), _("Suggests"), + _("Recommends"), _("Conflicts"), _("Replaces"), + _("Obsoletes"), _("Breaks"), _("Enhances")}; + if (Type < Types.size()) return Types[Type]; return ""; } +std::string_view pkgCache::DepType_NoL10n(unsigned char Type) +{ + std::array<std::string_view, 12> Types{"", "Depends", "PreDepends", "Suggests", + "Recommends", "Conflicts", "Replaces", + "Obsoletes", "Breaks", "Enhances"}; + if (Type < Types.size()) + return Types[Type]; + return {}; +} /*}}}*/ // Cache::Priority - Convert a priority value to a string /*{{{*/ -// --------------------------------------------------------------------- -/* */ const char *pkgCache::Priority(unsigned char Prio) { - const char *Mapping[] = {0,_("required"),_("important"),_("standard"), - _("optional"),_("extra")}; - if (Prio < APT_ARRAY_SIZE(Mapping)) + std::array<char const *, 6> Mapping{nullptr, _("required"), _("important"), _("standard"), + _("optional"), _("extra")}; + if (Prio < Mapping.size()) + return Mapping[Prio]; + return nullptr; +} +std::string_view pkgCache::Priority_NoL10n(unsigned char Prio) +{ + constexpr std::array<std::string_view, 6> const Mapping{ + "", "required", "important", "standard", "optional", "extra" + }; + if (Prio < Mapping.size()) return Mapping[Prio]; - return 0; + return {}; } /*}}}*/ // GrpIterator::FindPkg - Locate a package by arch /*{{{*/ |
