MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / hash

Function hash

include/hxString.h:223–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221 return __s[index];
222 }
223 inline unsigned int hash( ) const
224 {
225 if (!__s) return 0;
226 if ( __s[HX_GC_STRING_HASH_OFFSET] & HX_GC_STRING_HASH_BIT)
227 {
228 #ifdef HXCPP_PARANOID
229 unsigned int result = calcHash();
230
231 unsigned int have = (((unsigned int *)__s)[-1] & HX_GC_CONST_ALLOC_BIT) ?
232 ((unsigned int *)__s)[-2] : *((unsigned int *)(__s+length+1) );
233
234 if ( have != result )
235 {
236 printf("Bad string hash for %s\n", __s );
237 printf(" Is %08x\n", result );
238 printf(" Baked %08x\n", have );
239 printf(" Mark %08x\n", ((unsigned int *)__s)[-1] );
240 }
241 #endif
242 if (__s[HX_GC_CONST_ALLOC_MARK_OFFSET] & HX_GC_CONST_ALLOC_MARK_BIT)
243 {
244 #ifdef EMSCRIPTEN
245 return ((emscripten_align1_int*)__s)[-2];
246 #else
247 return ((unsigned int *)__s)[-2];
248 #endif
249 }
250 #ifdef EMSCRIPTEN
251 return *((emscripten_align1_int *)(__s+length+1) );
252 #else
253 return *((unsigned int *)(__s+length+1) );
254 #endif
255 }
256
257 // Slow path..
258 return calcHash();
259 }
260
261 unsigned int calcHash() const;
262 unsigned int calcSubHash(int start, int length) const;

Callers 1

String.cppFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected