From: Francesco Chemolli Date: Wed, 18 Dec 2013 15:22:06 +0000 (+0100) Subject: Reverted buggy change on CharacterSet::operator+=, documentation touches X-Git-Tag: SQUID_3_5_0_1~456^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d27140dbe16bcd376e2c752a68616aa9cec05b42;p=thirdparty%2Fsquid.git Reverted buggy change on CharacterSet::operator+=, documentation touches --- diff --git a/src/base/CharacterSet.cc b/src/base/CharacterSet.cc index 697276aed2..cabe47b6f5 100644 --- a/src/base/CharacterSet.cc +++ b/src/base/CharacterSet.cc @@ -1,18 +1,18 @@ #include "squid.h" - #include "CharacterSet.h" -#include - -static bool -isNonZero(uint8_t i) { - return i!=0; -} - const CharacterSet & CharacterSet::operator +=(const CharacterSet &src) { - std::copy_if(src.chars_.begin(),src.chars_.end(),chars_.begin(),isNonZero); + Storage::const_iterator s = src.chars_.begin(); + const Storage::const_iterator e = src.chars_.end(); + Storage::iterator d = chars_.begin(); + while (s != e) { + if (*s) + *d = 1; + ++s; + ++d; + } return *this; } @@ -24,7 +24,7 @@ CharacterSet::add(const unsigned char c) } CharacterSet::CharacterSet(const char *label, const char * const c) -: name(label == NULL ? "anonymous" : label), chars_(vector_type(256,0)) +: name(label == NULL ? "anonymous" : label), chars_(Storage(256,0)) { const size_t clen = strlen(c); for (size_t i = 0; i < clen; ++i) diff --git a/src/base/CharacterSet.h b/src/base/CharacterSet.h index 9b02c0cd87..48a613e9c3 100644 --- a/src/base/CharacterSet.h +++ b/src/base/CharacterSet.h @@ -3,20 +3,20 @@ #include -/// Optimized set of C chars, with quick membership test and merge support +/// optimized set of C chars, with quick membership test and merge support class CharacterSet { public: - typedef std::vector vector_type; + typedef std::vector Storage; - /// define a character set with the given label ("anonymous" if NULL, + /// define a character set with the given label ("anonymous" if NULL) /// with specified initial contents CharacterSet(const char *label, const char * const initial); /// whether a given character exists in the set - bool operator[](unsigned char c) const {return chars_[static_cast(c)] == 1;} + bool operator[](unsigned char c) const {return chars_[static_cast(c)] != 0;} - /// add a given character to the character set. + /// add a given character to the character set CharacterSet & add(const unsigned char c); /// add all characters from the given CharacterSet to this one @@ -26,13 +26,13 @@ public: const char * name; private: - /** characters present in this set. + /** index of characters in this set * * \note guaranteed to be always 256 slots big, as forced in the * constructor. This assumption is relied upon in operator[], add, * operator+= */ - vector_type chars_; + Storage chars_; }; #endif /* _SQUID_SRC_PARSER_CHARACTERSET_H */