Hi all, Expanding on the idea of passing a size other than 0 to zend_hash_init(), when possible, which was done awhile ago in a few areas (to save resize/rehash operations), I finally added an "array_init_size()" that can be used instead of array_init(), likewise, when a size is known. As an example to start, I updated these functions:
array_*: change_key_case, chunk, combine, fill, fill_keys, flip, keys (without $search_value), map, rand, reverse, slice, splice, unique (since it copies all entries first), values; and also compact; func_get_args; get_defined_vars; str_split; and a couple internal uses. Those were the simplest, most obvious cases I found. :-) I didn't test every function, but for example, the array functions that don't do much work I found to be ~10% faster (with more than 8 elements, otherwise no resizing would be needed). If these changes are applied, more can be done where possible, by others, or I can and send further patches, or update them myself if I have CVS access... http://realplain.com/php/array_init_size.diff http://realplain.com/php/array_init_size_5_3.diff I was playing with initializing scripts' array( ... ) constructs with the correct size too, but wasn't sure about the changes or what the opinion would be. Runtime creation is improved with >8 elements, though it adds a bit of compile overhead. Anyway, separate patches for that: http://realplain.com/php/array_init_size_vm.diff http://realplain.com/php/array_init_size_vm_5_3.diff Thanks, Matt -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php