mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 07:33:01 +00:00 
			
		
		
		
	Merge remote-tracking branch 'felixr/master' into master
This commit is contained in:
		| @@ -227,19 +227,21 @@ int32_t janet_string_calchash(const uint8_t *str, int32_t len) { | |||||||
| /* Computes hash of an array of values */ | /* Computes hash of an array of values */ | ||||||
| int32_t janet_array_calchash(const Janet *array, int32_t len) { | int32_t janet_array_calchash(const Janet *array, int32_t len) { | ||||||
|     const Janet *end = array + len; |     const Janet *end = array + len; | ||||||
|     uint32_t hash = 5381; |     uint32_t hash = 0; | ||||||
|     while (array < end) |     while (array < end) { | ||||||
|         hash = (hash << 5) + hash + janet_hash(*array++); |         uint32_t elem = janet_hash(*array++); | ||||||
|  |         hash ^= elem + 0x9e3779b9 + (hash << 6) + (hash >> 2); | ||||||
|  |     } | ||||||
|     return (int32_t) hash; |     return (int32_t) hash; | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Computes hash of an array of values */ | /* Computes hash of an array of values */ | ||||||
| int32_t janet_kv_calchash(const JanetKV *kvs, int32_t len) { | int32_t janet_kv_calchash(const JanetKV *kvs, int32_t len) { | ||||||
|     const JanetKV *end = kvs + len; |     const JanetKV *end = kvs + len; | ||||||
|     uint32_t hash = 5381; |     uint32_t hash = 0; | ||||||
|     while (kvs < end) { |     while (kvs < end) { | ||||||
|         hash = (hash << 5) + hash + janet_hash(kvs->key); |         hash ^= janet_hash(kvs->key) + 0x9e3779b9 + (hash << 6) + (hash >> 2); | ||||||
|         hash = (hash << 5) + hash + janet_hash(kvs->value); |         hash ^= janet_hash(kvs->value) + 0x9e3779b9 + (hash << 6) + (hash >> 2); | ||||||
|         kvs++; |         kvs++; | ||||||
|     } |     } | ||||||
|     return (int32_t) hash; |     return (int32_t) hash; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose