From b72b1a4e4d4a94a16b953bf8d826885efb56eeca Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 25 Nov 2017 16:07:51 +0100 Subject: Add zend_object_alloc() API Using ecalloc() to create objects is expensive, because the dynamic-size memset() is unreasonably slow. Make sure we only zero the main object structure with known size, as the properties are intialized separately anyway. Technically we do not need to zero the embedded zend_object structure either, but as long as the memset argument is constant, a couple more bytes don't really matter. --- ext/reflection/php_reflection.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'ext/reflection/php_reflection.c') diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 749c7e7656..d6b6d9718e 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -270,10 +270,7 @@ static HashTable *reflection_get_gc(zval *obj, zval **gc_data, int *gc_data_coun static zend_object *reflection_objects_new(zend_class_entry *class_type) /* {{{ */ { - reflection_object *intern; - - intern = ecalloc(1, sizeof(reflection_object) + zend_object_properties_size(class_type)); - intern->zo.ce = class_type; + reflection_object *intern = zend_object_alloc(sizeof(reflection_object), class_type); zend_object_std_init(&intern->zo, class_type); object_properties_init(&intern->zo, class_type); -- cgit v1.2.1