proxygen
proxygen::HTTPCommonHeadersInternal Class Reference

Static Public Member Functions

static const struct HTTPCommonHeaderNamein_word_set (const char *str, unsigned int len)
 

Static Private Member Functions

static unsigned int hash (const char *str, unsigned int len)
 

Detailed Description

Definition at line 111 of file HTTPCommonHeaders.cpp.

Member Function Documentation

unsigned int proxygen::HTTPCommonHeadersInternal::hash ( const char *  str,
unsigned int  len 
)
inlinestaticprivate

Definition at line 120 of file HTTPCommonHeaders.cpp.

References FOLLY_FALLTHROUGH.

121 {
122  static const unsigned char asso_values[] =
123  {
124  134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
125  134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
126  134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
127  134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
128  134, 134, 134, 134, 134, 6, 134, 134, 134, 134,
129  134, 134, 134, 6, 134, 134, 134, 134, 44, 134,
130  134, 134, 134, 134, 134, 0, 134, 4, 32, 2,
131  64, 58, 20, 17, 134, 77, 15, 31, 16, 39,
132  51, 134, 8, 0, 2, 45, 59, 38, 10, 55,
133  31, 134, 134, 134, 134, 134, 134, 0, 134, 4,
134  32, 2, 64, 58, 20, 17, 134, 77, 15, 31,
135  16, 39, 51, 134, 8, 0, 2, 45, 59, 38,
136  10, 55, 31, 134, 134, 134, 134, 134, 134, 134,
137  134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
138  134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
139  134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
140  134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
141  134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
142  134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
143  134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
144  134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
145  134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
146  134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
147  134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
148  134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
149  134, 134, 134, 134, 134, 134
150  };
151  register int hval = len;
152 
153  switch (hval)
154  {
155  default:
156  hval += asso_values[(unsigned char)str[21]];
158  case 21:
159  case 20:
160  case 19:
161  case 18:
162  case 17:
163  case 16:
164  case 15:
165  case 14:
166  case 13:
167  case 12:
168  case 11:
169  case 10:
170  case 9:
171  case 8:
172  hval += asso_values[(unsigned char)str[7]];
174  case 7:
175  case 6:
176  case 5:
177  case 4:
178  case 3:
179  case 2:
180  case 1:
181  hval += asso_values[(unsigned char)str[0]];
182  break;
183  }
184  return hval + asso_values[(unsigned char)str[len - 1]];
185 }
#define FOLLY_FALLTHROUGH
Definition: CppAttributes.h:63
const struct HTTPCommonHeaderName * proxygen::HTTPCommonHeadersInternal::in_word_set ( const char *  str,
unsigned int  len 
)
static

Definition at line 321 of file HTTPCommonHeaders.cpp.

References proxygen::gperf_case_memcmp(), proxygen::MIN_WORD_LENGTH, proxygen::HTTPCommonHeaderName::name, and s.

Referenced by proxygen::HTTPCommonHeaders::hash().

322 {
323  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
324  {
325  register int key = hash (str, len);
326 
327  if (key <= MAX_HASH_VALUE && key >= 0)
328  if (len == lengthtable[key])
329  {
330  register const char *s = wordlist[key].name;
331 
332  if ((((unsigned char)*str ^ (unsigned char)*s) & ~32) == 0 && !gperf_case_memcmp (str, s, len))
333  return &wordlist[key];
334  }
335  }
336  return 0;
337 }
static unsigned int hash(const char *str, unsigned int len)
static const struct HTTPCommonHeaderName wordlist[]
static set< string > s
static const unsigned char lengthtable[]
static int gperf_case_memcmp(register const char *s1, register const char *s2, register unsigned int n)

The documentation for this class was generated from the following file: