MCPcopy Create free account
hub / github.com/apache/impala / BuildLookupTable

Function BuildLookupTable

be/src/gutil/strings/stringpiece.cc:118–125  ·  view source on GitHub ↗

For each character in characters_wanted, sets the index corresponding to the ASCII code of that character to 1 in table. This is used by the find_.*_of methods below to tell whether or not a character is in the lookup table in constant time. The argument `table' must be an array that is large enough to hold all the possible values of an unsigned char. Thus it should be be declared as follows: bo

Source from the content-addressed store, hash-verified

116// as follows:
117// bool table[UCHAR_MAX + 1]
118static inline void BuildLookupTable(StringPiece characters_wanted,
119 bool* table) {
120 const int length = characters_wanted.length();
121 const char* const data = characters_wanted.data();
122 for (int i = 0; i < length; ++i) {
123 table[static_cast<unsigned char>(data[i])] = true;
124 }
125}
126
127int StringPiece::find_first_of(StringPiece s, size_type pos) const {
128 if (length_ <= 0 || s.length_ <= 0) {

Callers 4

find_first_ofMethod · 0.85
find_first_not_ofMethod · 0.85
find_last_ofMethod · 0.85
find_last_not_ofMethod · 0.85

Calls 2

lengthMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected