Home | History | Annotate | Download | only in base
      1 /* C++ code produced by gperf version 3.0.3 */
      2 /* Command-line: gperf -a -L C++ -C -c -o -t -k '*' -NFindDomain -ZPerfect_Hash_Test2 -D -T effective_tld_names_unittest2.gperf  */
      3 
      4 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
      5       && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
      6       && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
      7       && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
      8       && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
      9       && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
     10       && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
     11       && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
     12       && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
     13       && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
     14       && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
     15       && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
     16       && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
     17       && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
     18       && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
     19       && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
     20       && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
     21       && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
     22       && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
     23       && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
     24       && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
     25       && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
     26       && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
     27 /* The character set is not based on ISO-646.  */
     28 #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf (at) gnu.org>."
     29 #endif
     30 
     31 #line 1 "effective_tld_names_unittest2.gperf"
     32 
     33 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
     34 // Use of this source code is governed by a BSD-style license that
     35 // can be found in the LICENSE file.
     36 // Test file used by registry_controlled_domain_unittest.
     37 // We edit this file manually, then run
     38 // gperf -a -L "C++" -C -c -o -t -k '*' -NFindDomain -ZPerfect_Hash_Test2 -D -T effective_tld_names_unittest2.gperf >  effective_tld_names_unittest2.cc
     39 // to generate the perfect hashmap.
     40 
     41 #define TOTAL_KEYWORDS 2
     42 #define MIN_WORD_LENGTH 2
     43 #define MAX_WORD_LENGTH 6
     44 #define MIN_HASH_VALUE 2
     45 #define MAX_HASH_VALUE 6
     46 /* maximum key range = 5, duplicates = 0 */
     47 
     48 class Perfect_Hash_Test2
     49 {
     50 private:
     51   static inline unsigned int hash (const char *str, unsigned int len);
     52 public:
     53   static const struct DomainRule *FindDomain (const char *str, unsigned int len);
     54 };
     55 
     56 inline unsigned int
     57 Perfect_Hash_Test2::hash (register const char *str, register unsigned int len)
     58 {
     59   static const unsigned char asso_values[] =
     60     {
     61       7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     62       7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     63       7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     64       7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     65       7, 7, 7, 7, 7, 7, 0, 7, 7, 7,
     66       7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     67       7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     68       7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     69       7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     70       7, 7, 7, 7, 7, 7, 7, 0, 0, 7,
     71       7, 7, 7, 7, 7, 7, 0, 7, 7, 7,
     72       7, 7, 0, 7, 0, 7, 7, 7, 7, 7,
     73       7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     74       7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     75       7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     76       7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     77       7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     78       7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     79       7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     80       7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     81       7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     82       7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     83       7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     84       7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     85       7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     86       7, 7, 7, 7, 7, 7
     87     };
     88   register int hval = len;
     89 
     90   switch (hval)
     91     {
     92       default:
     93         hval += asso_values[(unsigned char)str[5]];
     94       /*FALLTHROUGH*/
     95       case 5:
     96         hval += asso_values[(unsigned char)str[4]];
     97       /*FALLTHROUGH*/
     98       case 4:
     99         hval += asso_values[(unsigned char)str[3]];
    100       /*FALLTHROUGH*/
    101       case 3:
    102         hval += asso_values[(unsigned char)str[2]];
    103       /*FALLTHROUGH*/
    104       case 2:
    105         hval += asso_values[(unsigned char)str[1]];
    106       /*FALLTHROUGH*/
    107       case 1:
    108         hval += asso_values[(unsigned char)str[0]];
    109         break;
    110     }
    111   return hval;
    112 }
    113 
    114 const struct DomainRule *
    115 Perfect_Hash_Test2::FindDomain (register const char *str, register unsigned int len)
    116 {
    117   static const struct DomainRule wordlist[] =
    118     {
    119 #line 15 "effective_tld_names_unittest2.gperf"
    120       {"jp", 0},
    121 #line 16 "effective_tld_names_unittest2.gperf"
    122       {"bar.jp", 0}
    123     };
    124 
    125   static const signed char lookup[] =
    126     {
    127       -1, -1,  0, -1, -1, -1,  1
    128     };
    129 
    130   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
    131     {
    132       register int key = hash (str, len);
    133 
    134       if (key <= MAX_HASH_VALUE && key >= 0)
    135         {
    136           register int index = lookup[key];
    137 
    138           if (index >= 0)
    139             {
    140               register const char *s = wordlist[index].name;
    141 
    142               if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
    143                 return &wordlist[index];
    144             }
    145         }
    146     }
    147   return 0;
    148 }
    149 #line 17 "effective_tld_names_unittest2.gperf"
    150 
    151