PHP 关联数组的哈希函数
Hash function for PHP associative arrays
我了解到 PHP 关联数组存储在哈希 Table 中。
字符串 'keys' 使用什么散列函数?
来自zend/hash.h:
/*
* DJBX33A (Daniel J. Bernstein, Times 33 with Addition)
*
* This is Daniel J. Bernstein's popular `times 33' hash function as
* posted by him years ago on comp.lang.c. It basically uses a function
* like ``hash(i) = hash(i-1) * 33 + str[i]''. This is one of the best
* known hash functions for strings. Because it is both computed very
* fast and distributes very well.
*
[...]
* -- Ralf S. Engelschall
*/
static inline ulong zend_inline_hash_func(const char *arKey, uint nKeyLength)
我了解到 PHP 关联数组存储在哈希 Table 中。 字符串 'keys' 使用什么散列函数?
来自zend/hash.h:
/* * DJBX33A (Daniel J. Bernstein, Times 33 with Addition) * * This is Daniel J. Bernstein's popular `times 33' hash function as * posted by him years ago on comp.lang.c. It basically uses a function * like ``hash(i) = hash(i-1) * 33 + str[i]''. This is one of the best * known hash functions for strings. Because it is both computed very * fast and distributes very well. * [...] * -- Ralf S. Engelschall */ static inline ulong zend_inline_hash_func(const char *arKey, uint nKeyLength)