Created
December 31, 2010 15:48
-
-
Save anonymous/761096 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: apc_bin.c | |
=================================================================== | |
--- apc_bin.c 2010-11-30 11:18:31.000000000 +0100 | |
+++ apc_bin.c 2010-12-30 17:11:03.000000000 +0100 | |
@@ -412,12 +412,6 @@ | |
if((*bp_prev)->pListLast) { | |
apc_swizzle_ptr(bd, ll, &(*bp_prev)->pListLast); | |
} | |
- if((*bp_prev)->pNext) { | |
- apc_swizzle_ptr(bd, ll, &(*bp_prev)->pNext); | |
- } | |
- if((*bp_prev)->pLast) { | |
- apc_swizzle_ptr(bd, ll, &(*bp_prev)->pLast); | |
- } | |
apc_swizzle_ptr(bd, ll, bp_prev); | |
} | |
for(i=0; i < ht->nTableSize; i++) { | |
Index: apc_compile.c | |
=================================================================== | |
--- apc_compile.c 2010-11-30 11:18:31.000000000 +0100 | |
+++ apc_compile.c 2010-12-30 17:12:28.000000000 +0100 | |
@@ -800,6 +800,7 @@ | |
Bucket* newp = NULL; | |
int first = 1; | |
apc_pool* pool = ctxt->pool; | |
+ void* t; | |
assert(src != NULL); | |
@@ -810,14 +811,17 @@ | |
memcpy(dst, src, sizeof(src[0])); | |
/* allocate buckets for the new hashtable */ | |
- CHECK((dst->arBuckets = apc_pool_alloc(pool, (dst->nTableSize * sizeof(Bucket*))))); | |
+ CHECK((t = apc_pool_alloc(pool, (dst->nTableSize * (sizeof(Bucket*) + 1))))); | |
- memset(dst->arBuckets, 0, dst->nTableSize * sizeof(Bucket*)); | |
+ memset(t, 0, dst->nTableSize * (sizeof(Bucket*) + 1)); | |
+ | |
+ dst->arBuckets = (Bucket**)t; | |
+ dst->arEmpty = ((uchar*)t) + (src->nTableSize * (sizeof(Bucket*))); | |
dst->pInternalPointer = NULL; | |
dst->pListHead = NULL; | |
for (curr = src->pListHead; curr != NULL; curr = curr->pListNext) { | |
- int n = curr->h % dst->nTableSize; | |
+ int n = ZEND_HASH_BUCKET(dst, curr->h); | |
if(check_fn) { | |
va_list args; | |
@@ -863,16 +867,8 @@ | |
#endif | |
/* insert 'newp' into the linked list at its hashed index */ | |
- if (dst->arBuckets[n]) { | |
- newp->pNext = dst->arBuckets[n]; | |
- newp->pLast = NULL; | |
- newp->pNext->pLast = newp; | |
- } | |
- else { | |
- newp->pNext = newp->pLast = NULL; | |
- } | |
- | |
- dst->arBuckets[n] = newp; | |
+ ZEND_HASH_FIND_FREE(dst, n); | |
+ ZEND_HASH_FILL_BUCKET(dst, n, newp); | |
/* copy the bucket data using our 'copy_fn' callback function */ | |
CHECK((newp->pData = copy_fn(NULL, curr->pData, ctxt TSRMLS_CC))); | |
@@ -1917,11 +1913,9 @@ | |
uint i; | |
for (i = 0; i < ht->nTableSize; i++) { | |
- if(!ht->arBuckets) break; | |
- p = ht->arBuckets[i]; | |
- while (p != NULL) { | |
+ if (ZEND_HASH_BUCKET_IS_OCCUPIED(ht, i)) { | |
+ p = ht->arBuckets[i]; | |
fixup(p, src, dst); | |
- p = p->pNext; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment