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/spl | |
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/spl')
-rw-r--r-- | ext/spl/spl_array.c | 2 | ||||
-rw-r--r-- | ext/spl/spl_directory.c | 2 | ||||
-rw-r--r-- | ext/spl/spl_dllist.c | 2 | ||||
-rw-r--r-- | ext/spl/spl_fixedarray.c | 2 | ||||
-rw-r--r-- | ext/spl/spl_heap.c | 2 | ||||
-rw-r--r-- | ext/spl/spl_iterators.c | 4 |
6 files changed, 7 insertions, 7 deletions
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index a9645ec61d..4e7faa404a 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -173,7 +173,7 @@ static zend_object *spl_array_object_new_ex(zend_class_entry *class_type, zval * zend_class_entry *parent = class_type; int inherited = 0; - intern = ecalloc(1, sizeof(spl_array_object) + zend_object_properties_size(parent)); + intern = zend_object_alloc(sizeof(spl_array_object), parent); zend_object_std_init(&intern->std, class_type); object_properties_init(&intern->std, class_type); diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 943b5174a2..c320e9c110 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -157,7 +157,7 @@ static zend_object *spl_filesystem_object_new_ex(zend_class_entry *class_type) { spl_filesystem_object *intern; - intern = ecalloc(1, sizeof(spl_filesystem_object) + zend_object_properties_size(class_type)); + intern = zend_object_alloc(sizeof(spl_filesystem_object), class_type); /* intern->type = SPL_FS_INFO; done by set 0 */ intern->file_class = spl_ce_SplFileObject; intern->info_class = spl_ce_SplFileInfo; diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index 1f594293cd..7b2f677d81 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -373,7 +373,7 @@ static zend_object *spl_dllist_object_new_ex(zend_class_entry *class_type, zval zend_class_entry *parent = class_type; int inherited = 0; - intern = ecalloc(1, sizeof(spl_dllist_object) + zend_object_properties_size(parent)); + intern = zend_object_alloc(sizeof(spl_dllist_object), parent); zend_object_std_init(&intern->std, class_type); object_properties_init(&intern->std, class_type); diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index 20fe02fd74..cd2f2ac123 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -210,7 +210,7 @@ static zend_object *spl_fixedarray_object_new_ex(zend_class_entry *class_type, z zend_class_entry *parent = class_type; int inherited = 0; - intern = ecalloc(1, sizeof(spl_fixedarray_object) + zend_object_properties_size(parent)); + intern = zend_object_alloc(sizeof(spl_fixedarray_object), parent); zend_object_std_init(&intern->std, class_type); object_properties_init(&intern->std, class_type); diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c index 5fecbfd290..38ce4c6241 100644 --- a/ext/spl/spl_heap.c +++ b/ext/spl/spl_heap.c @@ -363,7 +363,7 @@ static zend_object *spl_heap_object_new_ex(zend_class_entry *class_type, zval *o zend_class_entry *parent = class_type; int inherited = 0; - intern = ecalloc(1, sizeof(spl_heap_object) + zend_object_properties_size(parent)); + intern = zend_object_alloc(sizeof(spl_heap_object), parent); zend_object_std_init(&intern->std, class_type); object_properties_init(&intern->std, class_type); diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index da4af5a726..7d33aac322 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -961,7 +961,7 @@ static zend_object *spl_RecursiveIteratorIterator_new_ex(zend_class_entry *class { spl_recursive_it_object *intern; - intern = ecalloc(1, sizeof(spl_recursive_it_object) + zend_object_properties_size(class_type)); + intern = zend_object_alloc(sizeof(spl_recursive_it_object), class_type); if (init_prefix) { smart_str_appendl(&intern->prefix[0], "", 0); @@ -2360,7 +2360,7 @@ static zend_object *spl_dual_it_new(zend_class_entry *class_type) { spl_dual_it_object *intern; - intern = ecalloc(1, sizeof(spl_dual_it_object) + zend_object_properties_size(class_type)); + intern = zend_object_alloc(sizeof(spl_dual_it_object), class_type); intern->dit_type = DIT_Unknown; zend_object_std_init(&intern->std, class_type); |