Changeset 1334 in kBuild for trunk/src/kmk/variable.c
- Timestamp:
- Dec 2, 2007 9:07:24 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/variable.c
r1292 r1334 112 112 typedef signed short int int16_t; 113 113 # endif 114 static inline unsigned long variable_hash_2i(register const unsigned char *var, register int length) 115 { 114 static inline unsigned long variable_hash_2i(register const char *var, register int length) 115 { 116 register const unsigned char *uvar = (const unsigned char *)var; 116 117 register unsigned int hash = 0; 117 var += length;118 uvar += length; 118 119 switch (length) 119 120 { 120 121 default: 121 case 16: hash = *-- var + (hash << 6) + (hash << 16) - hash;122 case 15: hash = *-- var + (hash << 6) + (hash << 16) - hash;123 case 14: hash = *-- var + (hash << 6) + (hash << 16) - hash;124 case 13: hash = *-- var + (hash << 6) + (hash << 16) - hash;125 case 12: hash = *-- var + (hash << 6) + (hash << 16) - hash;126 case 11: hash = *-- var + (hash << 6) + (hash << 16) - hash;127 case 10: hash = *-- var + (hash << 6) + (hash << 16) - hash;128 case 9: hash = *-- var + (hash << 6) + (hash << 16) - hash;129 case 8: hash = *-- var + (hash << 6) + (hash << 16) - hash;130 case 7: hash = *-- var + (hash << 6) + (hash << 16) - hash;131 case 6: hash = *-- var + (hash << 6) + (hash << 16) - hash;132 case 5: hash = *-- var + (hash << 6) + (hash << 16) - hash;133 case 4: hash = *-- var + (hash << 6) + (hash << 16) - hash;134 case 3: hash = *-- var + (hash << 6) + (hash << 16) - hash;135 case 2: hash = *-- var + (hash << 6) + (hash << 16) - hash;136 case 1: hash = *-- var + (hash << 6) + (hash << 16) - hash;122 case 16: hash = *--uvar + (hash << 6) + (hash << 16) - hash; 123 case 15: hash = *--uvar + (hash << 6) + (hash << 16) - hash; 124 case 14: hash = *--uvar + (hash << 6) + (hash << 16) - hash; 125 case 13: hash = *--uvar + (hash << 6) + (hash << 16) - hash; 126 case 12: hash = *--uvar + (hash << 6) + (hash << 16) - hash; 127 case 11: hash = *--uvar + (hash << 6) + (hash << 16) - hash; 128 case 10: hash = *--uvar + (hash << 6) + (hash << 16) - hash; 129 case 9: hash = *--uvar + (hash << 6) + (hash << 16) - hash; 130 case 8: hash = *--uvar + (hash << 6) + (hash << 16) - hash; 131 case 7: hash = *--uvar + (hash << 6) + (hash << 16) - hash; 132 case 6: hash = *--uvar + (hash << 6) + (hash << 16) - hash; 133 case 5: hash = *--uvar + (hash << 6) + (hash << 16) - hash; 134 case 4: hash = *--uvar + (hash << 6) + (hash << 16) - hash; 135 case 3: hash = *--uvar + (hash << 6) + (hash << 16) - hash; 136 case 2: hash = *--uvar + (hash << 6) + (hash << 16) - hash; 137 case 1: hash = *--uvar + (hash << 6) + (hash << 16) - hash; 137 138 case 0: 138 139 break; … … 141 142 } 142 143 143 static inline unsigned long variable_hash_1i(register const unsigned char *var, register int length) 144 { 145 register unsigned int hash = ((5381 << 5) + 5381) + *var; 144 static inline unsigned long variable_hash_1i(register const char *var, register int length) 145 { 146 register const unsigned char *uvar = (const unsigned char *)var; 147 register unsigned int hash = ((5381 << 5) + 5381) + *uvar; 146 148 switch (length) 147 149 { 148 150 default: 149 case 8: hash = ((hash << 5) + hash) + var[7];150 case 7: hash = ((hash << 5) + hash) + var[6];151 case 6: hash = ((hash << 5) + hash) + var[5];152 case 5: hash = ((hash << 5) + hash) + var[4];153 case 4: hash = ((hash << 5) + hash) + var[3];154 case 3: hash = ((hash << 5) + hash) + var[2];155 case 2: hash = ((hash << 5) + hash) + var[1];151 case 8: hash = ((hash << 5) + hash) + uvar[7]; 152 case 7: hash = ((hash << 5) + hash) + uvar[6]; 153 case 6: hash = ((hash << 5) + hash) + uvar[5]; 154 case 5: hash = ((hash << 5) + hash) + uvar[4]; 155 case 4: hash = ((hash << 5) + hash) + uvar[3]; 156 case 3: hash = ((hash << 5) + hash) + uvar[2]; 157 case 2: hash = ((hash << 5) + hash) + uvar[1]; 156 158 case 1: return hash; 157 159 case 0: return 5381; /* shouldn't happen */
Note:
See TracChangeset
for help on using the changeset viewer.