mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-26 18:35:42 +00:00
revamp the hash api once more
This commit is contained in:
1 parent
173bd989cd
commit
e2df932ef0
4 files changed
+37
-37
No files matched your search
+1
-1
@@ -1016,7 +1016,7 @@ ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args TSRMLS_DC,
|
||||
/* }}} */
|
||||
|
||||
/* Argument parsing API -- andrei */
|
||||
ZEND_API int _array_init(zval *arg, uint size ZEND_FILE_LINE_DC) /* {{{ */
|
||||
ZEND_API int _array_init(zval *arg, zend_uint_t size ZEND_FILE_LINE_DC) /* {{{ */
|
||||
{
|
||||
ALLOC_HASHTABLE_REL(Z_ARRVAL_P(arg));
|
||||
|
||||
|
||||
+1
-1
@@ -364,7 +364,7 @@ ZEND_API char *zend_get_type_by_const(int type);
|
||||
#define object_init(arg) _object_init((arg) ZEND_FILE_LINE_CC TSRMLS_CC)
|
||||
#define object_init_ex(arg, ce) _object_init_ex((arg), (ce) ZEND_FILE_LINE_CC TSRMLS_CC)
|
||||
#define object_and_properties_init(arg, ce, properties) _object_and_properties_init((arg), (ce), (properties) ZEND_FILE_LINE_CC TSRMLS_CC)
|
||||
ZEND_API int _array_init(zval *arg, uint size ZEND_FILE_LINE_DC);
|
||||
ZEND_API int _array_init(zval *arg, zend_uint_t size ZEND_FILE_LINE_DC);
|
||||
ZEND_API int _object_init(zval *arg ZEND_FILE_LINE_DC TSRMLS_DC);
|
||||
ZEND_API int _object_init_ex(zval *arg, zend_class_entry *ce ZEND_FILE_LINE_DC TSRMLS_DC);
|
||||
ZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *ce, HashTable *properties ZEND_FILE_LINE_DC TSRMLS_DC);
|
||||
|
||||
+23
-23
@@ -141,9 +141,9 @@ ZEND_API zend_uint_t zend_hash_func(const char *arKey, zend_size_t nKeyLength)
|
||||
|
||||
static const Bucket *uninitialized_bucket = NULL;
|
||||
|
||||
ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC)
|
||||
ZEND_API int _zend_hash_init(HashTable *ht, zend_uint_t nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC)
|
||||
{
|
||||
uint i = 3;
|
||||
zend_uint_t i = 3;
|
||||
|
||||
SET_INCONSISTENT(HT_OK);
|
||||
|
||||
@@ -151,7 +151,7 @@ ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, dtor_func_t pDestructor,
|
||||
/* prevent overflow */
|
||||
ht->nTableSize = 0x80000000;
|
||||
} else {
|
||||
while ((1U << i) < nSize) {
|
||||
while ((Z_UI(1) << i) < nSize) {
|
||||
i++;
|
||||
}
|
||||
ht->nTableSize = 1 << i;
|
||||
@@ -172,7 +172,7 @@ ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, dtor_func_t pDestructor,
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int _zend_hash_init_ex(HashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC)
|
||||
ZEND_API int _zend_hash_init_ex(HashTable *ht, zend_uint_t nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC)
|
||||
{
|
||||
int retval = _zend_hash_init(ht, nSize, pDestructor, persistent ZEND_FILE_LINE_CC);
|
||||
|
||||
@@ -188,10 +188,10 @@ ZEND_API void zend_hash_set_apply_protection(HashTable *ht, zend_bool bApplyProt
|
||||
|
||||
|
||||
|
||||
ZEND_API int _zend_hash_add_or_update(HashTable *ht, const char *arKey, zend_size_t nKeyLength, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC)
|
||||
ZEND_API int _zend_hash_add_or_update(HashTable *ht, const char *arKey, zend_size_t nKeyLength, void *pData, zend_uint_t nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC)
|
||||
{
|
||||
zend_uint_t h;
|
||||
uint nIndex;
|
||||
zend_uint_t nIndex;
|
||||
Bucket *p;
|
||||
#ifdef ZEND_SIGNALS
|
||||
TSRMLS_FETCH();
|
||||
@@ -254,9 +254,9 @@ ZEND_API int _zend_hash_add_or_update(HashTable *ht, const char *arKey, zend_siz
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
ZEND_API int _zend_hash_quick_add_or_update(HashTable *ht, const char *arKey, zend_size_t nKeyLength, zend_uint_t h, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC)
|
||||
ZEND_API int _zend_hash_quick_add_or_update(HashTable *ht, const char *arKey, zend_size_t nKeyLength, zend_uint_t h, void *pData, zend_uint_t nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC)
|
||||
{
|
||||
uint nIndex;
|
||||
zend_uint_t nIndex;
|
||||
Bucket *p;
|
||||
#ifdef ZEND_SIGNALS
|
||||
TSRMLS_FETCH();
|
||||
@@ -329,9 +329,9 @@ ZEND_API int zend_hash_add_empty_element(HashTable *ht, const char *arKey, zend_
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int _zend_hash_index_update_or_next_insert(HashTable *ht, zend_uint_t h, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC)
|
||||
ZEND_API int _zend_hash_index_update_or_next_insert(HashTable *ht, zend_uint_t h, void *pData, zend_uint_t nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC)
|
||||
{
|
||||
uint nIndex;
|
||||
zend_uint_t nIndex;
|
||||
Bucket *p;
|
||||
#ifdef ZEND_SIGNALS
|
||||
TSRMLS_FETCH();
|
||||
@@ -416,7 +416,7 @@ static void zend_hash_do_resize(HashTable *ht)
|
||||
ZEND_API int zend_hash_rehash(HashTable *ht)
|
||||
{
|
||||
Bucket *p;
|
||||
uint nIndex;
|
||||
zend_uint_t nIndex;
|
||||
|
||||
IS_CONSISTENT(ht);
|
||||
if (UNEXPECTED(ht->nNumOfElements == 0)) {
|
||||
@@ -436,7 +436,7 @@ ZEND_API int zend_hash_rehash(HashTable *ht)
|
||||
|
||||
ZEND_API int zend_hash_del_key_or_index(HashTable *ht, const char *arKey, zend_size_t nKeyLength, zend_uint_t h, int flag)
|
||||
{
|
||||
uint nIndex;
|
||||
zend_uint_t nIndex;
|
||||
Bucket *p;
|
||||
#ifdef ZEND_SIGNALS
|
||||
TSRMLS_FETCH();
|
||||
@@ -569,7 +569,7 @@ static Bucket *zend_hash_apply_deleter(HashTable *ht, Bucket *p)
|
||||
if (p->pLast) {
|
||||
p->pLast->pNext = p->pNext;
|
||||
} else {
|
||||
uint nIndex;
|
||||
zend_uint_t nIndex;
|
||||
|
||||
nIndex = p->h & ht->nTableMask;
|
||||
ht->arBuckets[nIndex] = p->pNext;
|
||||
@@ -762,7 +762,7 @@ ZEND_API void zend_hash_reverse_apply(HashTable *ht, apply_func_t apply_func TSR
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_hash_copy(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size)
|
||||
ZEND_API void zend_hash_copy(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, zend_uint_t size)
|
||||
{
|
||||
Bucket *p;
|
||||
void *new_entry;
|
||||
@@ -793,7 +793,7 @@ ZEND_API void zend_hash_copy(HashTable *target, HashTable *source, copy_ctor_fun
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void _zend_hash_merge(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size, int overwrite ZEND_FILE_LINE_DC)
|
||||
ZEND_API void _zend_hash_merge(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, zend_uint_t size, int overwrite ZEND_FILE_LINE_DC)
|
||||
{
|
||||
Bucket *p;
|
||||
void *t;
|
||||
@@ -830,7 +830,7 @@ static zend_bool zend_hash_replace_checker_wrapper(HashTable *target, void *sour
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_hash_merge_ex(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, uint size, merge_checker_func_t pMergeSource, void *pParam)
|
||||
ZEND_API void zend_hash_merge_ex(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, zend_uint_t size, merge_checker_func_t pMergeSource, void *pParam)
|
||||
{
|
||||
Bucket *p;
|
||||
void *t;
|
||||
@@ -858,7 +858,7 @@ ZEND_API void zend_hash_merge_ex(HashTable *target, HashTable *source, copy_ctor
|
||||
ZEND_API int zend_hash_find(const HashTable *ht, const char *arKey, zend_size_t nKeyLength, void **pData)
|
||||
{
|
||||
zend_uint_t h;
|
||||
uint nIndex;
|
||||
zend_uint_t nIndex;
|
||||
Bucket *p;
|
||||
|
||||
IS_CONSISTENT(ht);
|
||||
@@ -881,7 +881,7 @@ ZEND_API int zend_hash_find(const HashTable *ht, const char *arKey, zend_size_t
|
||||
|
||||
ZEND_API int zend_hash_quick_find(const HashTable *ht, const char *arKey, zend_size_t nKeyLength, zend_uint_t h, void **pData)
|
||||
{
|
||||
uint nIndex;
|
||||
zend_uint_t nIndex;
|
||||
Bucket *p;
|
||||
|
||||
ZEND_ASSERT(nKeyLength != 0);
|
||||
@@ -906,7 +906,7 @@ ZEND_API int zend_hash_quick_find(const HashTable *ht, const char *arKey, zend_s
|
||||
ZEND_API int zend_hash_exists(const HashTable *ht, const char *arKey, zend_size_t nKeyLength)
|
||||
{
|
||||
zend_uint_t h;
|
||||
uint nIndex;
|
||||
zend_uint_t nIndex;
|
||||
Bucket *p;
|
||||
|
||||
IS_CONSISTENT(ht);
|
||||
@@ -928,7 +928,7 @@ ZEND_API int zend_hash_exists(const HashTable *ht, const char *arKey, zend_size_
|
||||
|
||||
ZEND_API int zend_hash_quick_exists(const HashTable *ht, const char *arKey, zend_size_t nKeyLength, zend_uint_t h)
|
||||
{
|
||||
uint nIndex;
|
||||
zend_uint_t nIndex;
|
||||
Bucket *p;
|
||||
|
||||
ZEND_ASSERT(nKeyLength != 0);
|
||||
@@ -952,7 +952,7 @@ ZEND_API int zend_hash_quick_exists(const HashTable *ht, const char *arKey, zend
|
||||
|
||||
ZEND_API int zend_hash_index_find(const HashTable *ht, zend_uint_t h, void **pData)
|
||||
{
|
||||
uint nIndex;
|
||||
zend_uint_t nIndex;
|
||||
Bucket *p;
|
||||
|
||||
IS_CONSISTENT(ht);
|
||||
@@ -973,7 +973,7 @@ ZEND_API int zend_hash_index_find(const HashTable *ht, zend_uint_t h, void **pDa
|
||||
|
||||
ZEND_API int zend_hash_index_exists(const HashTable *ht, zend_uint_t h)
|
||||
{
|
||||
uint nIndex;
|
||||
zend_uint_t nIndex;
|
||||
Bucket *p;
|
||||
|
||||
IS_CONSISTENT(ht);
|
||||
@@ -1574,7 +1574,7 @@ void zend_hash_display_pListTail(const HashTable *ht)
|
||||
void zend_hash_display(const HashTable *ht)
|
||||
{
|
||||
Bucket *p;
|
||||
uint i;
|
||||
zend_uint_t i;
|
||||
|
||||
if (UNEXPECTED(ht->nNumOfElements == 0)) {
|
||||
zend_output_debug_string(0, "The hash is empty");
|
||||
|
||||
+12
-12
@@ -65,9 +65,9 @@ typedef struct bucket {
|
||||
} Bucket;
|
||||
|
||||
typedef struct _hashtable {
|
||||
uint nTableSize;
|
||||
uint nTableMask;
|
||||
uint nNumOfElements;
|
||||
zend_uint_t nTableSize;
|
||||
zend_uint_t nTableMask;
|
||||
zend_uint_t nNumOfElements;
|
||||
zend_uint_t nNextFreeElement;
|
||||
Bucket *pInternalPointer; /* Used for element traversal */
|
||||
Bucket *pListHead;
|
||||
@@ -97,27 +97,27 @@ typedef Bucket* HashPosition;
|
||||
BEGIN_EXTERN_C()
|
||||
|
||||
/* startup/shutdown */
|
||||
ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC);
|
||||
ZEND_API int _zend_hash_init_ex(HashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC);
|
||||
ZEND_API int _zend_hash_init(HashTable *ht, zend_uint_t nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC);
|
||||
ZEND_API int _zend_hash_init_ex(HashTable *ht, zend_uint_t nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC);
|
||||
ZEND_API void zend_hash_destroy(HashTable *ht);
|
||||
ZEND_API void zend_hash_clean(HashTable *ht);
|
||||
#define zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent) _zend_hash_init((ht), (nSize), (pDestructor), (persistent) ZEND_FILE_LINE_CC)
|
||||
#define zend_hash_init_ex(ht, nSize, pHashFunction, pDestructor, persistent, bApplyProtection) _zend_hash_init_ex((ht), (nSize), (pDestructor), (persistent), (bApplyProtection) ZEND_FILE_LINE_CC)
|
||||
|
||||
/* additions/updates/changes */
|
||||
ZEND_API int _zend_hash_add_or_update(HashTable *ht, const char *arKey, zend_size_t nKeyLength, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC);
|
||||
ZEND_API int _zend_hash_add_or_update(HashTable *ht, const char *arKey, zend_size_t nKeyLength, void *pData, zend_uint_t nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC);
|
||||
#define zend_hash_update(ht, arKey, nKeyLength, pData, nDataSize, pDest) \
|
||||
_zend_hash_add_or_update(ht, arKey, nKeyLength, pData, nDataSize, pDest, HASH_UPDATE ZEND_FILE_LINE_CC)
|
||||
#define zend_hash_add(ht, arKey, nKeyLength, pData, nDataSize, pDest) \
|
||||
_zend_hash_add_or_update(ht, arKey, nKeyLength, pData, nDataSize, pDest, HASH_ADD ZEND_FILE_LINE_CC)
|
||||
|
||||
ZEND_API int _zend_hash_quick_add_or_update(HashTable *ht, const char *arKey, zend_size_t nKeyLength, zend_uint_t h, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC);
|
||||
ZEND_API int _zend_hash_quick_add_or_update(HashTable *ht, const char *arKey, zend_size_t nKeyLength, zend_uint_t h, void *pData, zend_uint_t nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC);
|
||||
#define zend_hash_quick_update(ht, arKey, nKeyLength, h, pData, nDataSize, pDest) \
|
||||
_zend_hash_quick_add_or_update(ht, arKey, nKeyLength, h, pData, nDataSize, pDest, HASH_UPDATE ZEND_FILE_LINE_CC)
|
||||
#define zend_hash_quick_add(ht, arKey, nKeyLength, h, pData, nDataSize, pDest) \
|
||||
_zend_hash_quick_add_or_update(ht, arKey, nKeyLength, h, pData, nDataSize, pDest, HASH_ADD ZEND_FILE_LINE_CC)
|
||||
|
||||
ZEND_API int _zend_hash_index_update_or_next_insert(HashTable *ht, zend_uint_t h, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC);
|
||||
ZEND_API int _zend_hash_index_update_or_next_insert(HashTable *ht, zend_uint_t h, void *pData, zend_uint_t nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC);
|
||||
#define zend_hash_index_update(ht, h, pData, nDataSize, pDest) \
|
||||
_zend_hash_index_update_or_next_insert(ht, h, pData, nDataSize, pDest, HASH_UPDATE ZEND_FILE_LINE_CC)
|
||||
#define zend_hash_next_index_insert(ht, pData, nDataSize, pDest) \
|
||||
@@ -214,9 +214,9 @@ ZEND_API int zend_hash_set_pointer(HashTable *ht, const HashPointer *ptr);
|
||||
zend_hash_update_current_key_ex(ht, key_type, str_index, str_length, num_index, HASH_UPDATE_KEY_ANYWAY, NULL)
|
||||
|
||||
/* Copying, merging and sorting */
|
||||
ZEND_API void zend_hash_copy(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size);
|
||||
ZEND_API void _zend_hash_merge(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size, int overwrite ZEND_FILE_LINE_DC);
|
||||
ZEND_API void zend_hash_merge_ex(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, uint size, merge_checker_func_t pMergeSource, void *pParam);
|
||||
ZEND_API void zend_hash_copy(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, zend_uint_t size);
|
||||
ZEND_API void _zend_hash_merge(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, zend_uint_t size, int overwrite ZEND_FILE_LINE_DC);
|
||||
ZEND_API void zend_hash_merge_ex(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, zend_uint_t size, merge_checker_func_t pMergeSource, void *pParam);
|
||||
ZEND_API int zend_hash_sort(HashTable *ht, sort_func_t sort_func, compare_func_t compare_func, int renumber TSRMLS_DC);
|
||||
ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, zend_bool ordered TSRMLS_DC);
|
||||
ZEND_API int zend_hash_minmax(const HashTable *ht, compare_func_t compar, int flag, void **pData TSRMLS_DC);
|
||||
@@ -348,7 +348,7 @@ END_EXTERN_C()
|
||||
ZEND_HANDLE_NUMERIC_EX(key, length, idx, return func); \
|
||||
} while (0)
|
||||
|
||||
static inline int zend_symtable_update(HashTable *ht, const char *arKey, zend_size_t nKeyLength, void *pData, uint nDataSize, void **pDest) \
|
||||
static inline int zend_symtable_update(HashTable *ht, const char *arKey, zend_size_t nKeyLength, void *pData, zend_uint_t nDataSize, void **pDest) \
|
||||
{
|
||||
ZEND_HANDLE_NUMERIC(arKey, nKeyLength, zend_hash_index_update(ht, idx, pData, nDataSize, pDest));
|
||||
return zend_hash_update(ht, arKey, nKeyLength, pData, nDataSize, pDest);
|
||||
|
||||
Reference in new issue
Block a user