Add quick_exists()

This commit is contained in:
Zeev Suraski 2003-02-05 13:19:59 +00:00
parent da12870c68
commit 376d63170b
2 changed files with 30 additions and 0 deletions

View File

@ -938,6 +938,35 @@ ZEND_API int zend_hash_exists(HashTable *ht, char *arKey, uint nKeyLength)
}
ZEND_API int zend_hash_quick_exists(HashTable *ht, char *arKey, uint nKeyLength, ulong h)
{
uint nIndex;
Bucket *p;
if (nKeyLength==0) {
return zend_hash_index_exists(ht, h);
}
IS_CONSISTENT(ht);
HANDLE_NUMERIC(arKey, nKeyLength, zend_hash_index_exists(ht, idx));
nIndex = h & ht->nTableMask;
p = ht->arBuckets[nIndex];
while (p != NULL) {
if ((p->h == h) && (p->nKeyLength == nKeyLength)) {
if (!memcmp(p->arKey, arKey, nKeyLength)) {
return 1;
}
}
p = p->pNext;
}
return 0;
}
ZEND_API int zend_hash_index_find(HashTable *ht, ulong h, void **pData)
{
uint nIndex;

View File

@ -159,6 +159,7 @@ ZEND_API int zend_hash_index_find(HashTable *ht, ulong h, void **pData);
/* Misc */
ZEND_API int zend_hash_exists(HashTable *ht, char *arKey, uint nKeyLength);
ZEND_API int zend_hash_quick_exists(HashTable *ht, char *arKey, uint nKeyLength, ulong h);
ZEND_API int zend_hash_index_exists(HashTable *ht, ulong h);
ZEND_API ulong zend_hash_next_free_element(HashTable *ht);