diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2017-11-25 16:07:51 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2017-11-25 17:12:37 +0100 |
commit | b72b1a4e4d4a94a16b953bf8d826885efb56eeca (patch) | |
tree | d79e5390c77d3a5218f39262f2205280dacb8bf7 /ext/dom | |
parent | 8795893f4f90a344cc9a9d48523b7aa0ba5ebf05 (diff) | |
download | php-git-b72b1a4e4d4a94a16b953bf8d826885efb56eeca.tar.gz |
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.
Diffstat (limited to 'ext/dom')
-rw-r--r-- | ext/dom/php_dom.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index 8fdf6aa6e0..109f7c127a 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -1075,7 +1075,7 @@ void dom_namednode_iter(dom_object *basenode, int ntype, dom_object *intern, xml static dom_object* dom_objects_set_class(zend_class_entry *class_type, zend_bool hash_copy) /* {{{ */ { - dom_object *intern = ecalloc(1, sizeof(dom_object) + zend_object_properties_size(class_type)); + dom_object *intern = zend_object_alloc(sizeof(dom_object), class_type); zend_class_entry *base_class = class_type; while ((base_class->type != ZEND_INTERNAL_CLASS || base_class->info.internal.module->module_number != dom_module_entry.module_number) && base_class->parent != NULL) { @@ -1106,7 +1106,7 @@ zend_object *dom_objects_new(zend_class_entry *class_type) /* {{{ zend_object dom_xpath_objects_new(zend_class_entry *class_type) */ zend_object *dom_xpath_objects_new(zend_class_entry *class_type) { - dom_xpath_object *intern = ecalloc(1, sizeof(dom_xpath_object) + zend_object_properties_size(class_type)); + dom_xpath_object *intern = zend_object_alloc(sizeof(dom_xpath_object), class_type); intern->registered_phpfunctions = zend_new_array(0); |