From dfe66c72ffc010e019e96b35154e1ad4ab506a6e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 15 Jul 2015 14:36:16 +0200 Subject: use a smaller type for flags storage in the cache We store very few flags in the cache, so keeping storage space for 8 is enough for all of them and still leaves a few unused bits remaining for future extensions without wasting bytes for nothing. Git-Dch: Ignore --- apt-pkg/tagfile.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'apt-pkg/tagfile.cc') diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index 213a413cb..253b1b7a3 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -579,6 +579,34 @@ bool pkgTagSection::FindB(const char *Tag, bool const &Default) const // TagSection::FindFlag - Locate a yes/no type flag /*{{{*/ // --------------------------------------------------------------------- /* The bits marked in Flag are masked on/off in Flags */ +bool pkgTagSection::FindFlag(const char * const Tag, uint8_t &Flags, + uint8_t const Flag) const +{ + const char *Start; + const char *Stop; + if (Find(Tag,Start,Stop) == false) + return true; + return FindFlag(Flags, Flag, Start, Stop); +} +bool pkgTagSection::FindFlag(uint8_t &Flags, uint8_t const Flag, + char const* const Start, char const* const Stop) +{ + switch (StringToBool(string(Start, Stop))) + { + case 0: + Flags &= ~Flag; + return true; + + case 1: + Flags |= Flag; + return true; + + default: + _error->Warning("Unknown flag value: %s",string(Start,Stop).c_str()); + return true; + } + return true; +} bool pkgTagSection::FindFlag(const char *Tag,unsigned long &Flags, unsigned long Flag) const { -- cgit v1.2.3