php/php-src — pull request #630 by nikic (2014-03-21 22:06:01+00:00)
Title: Optimize hash bucket data storage

Old behavior: Hash bucket data pointer is stored in pData and the
actual data is stored either in pDataPtr (for pointer types) or
a separate allocation.

New behavior: Hash bucket data is appended to the bucket struct.
The bucket data pointer thus implicitly becomes
(void *) ((char *) Bucket + sizeof(Bucket)).

Memory impact: In every case the memory needed for the pData poitner
is saved. For non-pointer types the pDataPtr and allocation overhead
is saved additionally. In numbers:
* 32bit / ptr : 4 bytes (per bucket)
* 32bit / data: 16 bytes (per bucket)
* 64bit / ptr : 8 bytes (per bucket)
* 64bit / data: 32 bytes (per bucket)

Limitations: It is no longer possible to store variable length data
in a hashtable. This feature was never actually used in PHP.

API changes:

* zend_(hash|symtable)_update_current_key(_ex) now take an
additional nDataSize element. This is necessary because the
potential bucket reallocation needs to know the data size.
* External code making direct use of the Bucket structure must use
zend_bucket_data(Bucket *) instead of directly accessing the
pData member of the bucket. This mostly impacts custom comparison
functions for zend_hash_sort, as that is the only place where
well-behaving code is forced to directly operate on buckets.