summaryrefslogtreecommitdiff
path: root/processor
diff options
context:
space:
mode:
authorXuefer <xuefer@gmail.com>2014-11-11 17:10:13 +0000
committerXuefer <xuefer@gmail.com>2014-11-11 17:10:13 +0000
commit07183575efa06f2c59303739f45f7bb4c1791ca0 (patch)
tree0282f4888b8d5715f45ed2a14a9de4ef7cfdb7b9 /processor
parent30d56bf2d775fa30aa116778bb342a45b654e0a7 (diff)
downloadxcache-07183575efa06f2c59303739f45f7bb4c1791ca0.tar.gz
xcache-07183575efa06f2c59303739f45f7bb4c1791ca0.zip
use vector for objects/object_handles
git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1567 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
Diffstat (limited to 'processor')
-rw-r--r--processor/foot.m49
-rw-r--r--processor/processor.m48
-rw-r--r--processor/var-helper-t.h3
-rw-r--r--processor/var-helper.h12
4 files changed, 16 insertions, 16 deletions
diff --git a/processor/foot.m4 b/processor/foot.m4
index 69529a8..ac2ade4 100644
--- a/processor/foot.m4
+++ b/processor/foot.m4
@@ -135,10 +135,11 @@ EXPORTED_FUNCTION(`zval *xc_processor_restore_var(zval *dst, const xc_entry_var_
#ifdef ZEND_ENGINE_2
if (src->objects_count) {
zend_uint i;
- processor.object_handles = emalloc(sizeof(*processor.object_handles) * src->objects_count);
+ xc_vector_init(zend_object_handle, &processor.object_handles);
+ xc_vector_reserve(&processor.object_handles, src->objects_count);
for (i = 0; i < src->objects_count; ++i) {
zend_object *object = emalloc(sizeof(*object));
- processor.object_handles[i] = zend_objects_store_put(object, (zend_objects_store_dtor_t) zend_objects_destroy_object, (zend_objects_free_object_storage_t) zend_objects_free_object_storage, NULL TSRMLS_CC);
+ xc_vector_data(zend_object_handle, &processor.object_handles)[i] = zend_objects_store_put(object, (zend_objects_store_dtor_t) zend_objects_destroy_object, (zend_objects_free_object_storage_t) zend_objects_free_object_storage, NULL TSRMLS_CC);
xc_restore_zend_object(&processor, object, &src->objects[i] TSRMLS_CC);
}
}
@@ -152,9 +153,9 @@ EXPORTED_FUNCTION(`zval *xc_processor_restore_var(zval *dst, const xc_entry_var_
if (src->objects_count) {
zend_uint i;
for (i = 0; i < src->objects_count; ++i) {
- zend_objects_store_del_ref_by_handle(processor.object_handles[i] TSRMLS_CC);
+ zend_objects_store_del_ref_by_handle(xc_vector_data(zend_object_handle, &processor.object_handles)[i] TSRMLS_CC);
}
- efree(processor.object_handles);
+ xc_vector_destroy(&processor.object_handles);
}
#endif
diff --git a/processor/processor.m4 b/processor/processor.m4
index 25ba045..da4d689 100644
--- a/processor/processor.m4
+++ b/processor/processor.m4
@@ -1421,10 +1421,10 @@ DEF_STRUCT_P_FUNC(`xc_entry_var_t', , `dnl {{{
IFCALC(`
dnl objects = collect_from(value);
pushdef(`src', `vsrc')
- SRC(objects_count) = xc_vector_size(&processor->objects);
- SRC(objects) = xc_vector_detach(zend_object, &processor->objects);
+ SRC(objects_count) = xc_vector_size(&processor->object_handles);
+ SRC(objects) = xc_vector_detach(zend_object, &processor->object_handles);
popdef(`src')
- xc_vector_destroy(&processor->objects);
+ xc_vector_destroy(&processor->object_handles);
')
dnl must be after calc .value
PROCESS(zend_uint, objects_count)
@@ -1442,7 +1442,7 @@ DEF_STRUCT_P_FUNC(`xc_entry_var_t', , `dnl {{{
dnl classe_
IFCALC(`
- dnl class_names = collect_from(objects);
+ dnl class_names = collect_from(object_handles);
pushdef(`src', `vsrc')
SRC(class_names_count) = xc_vector_size(&processor->class_names);
SRC(class_names) = xc_vector_detach(xc_constant_string_t, &processor->class_names);
diff --git a/processor/var-helper-t.h b/processor/var-helper-t.h
index 25ef538..f8de297 100644
--- a/processor/var-helper-t.h
+++ b/processor/var-helper-t.h
@@ -1,8 +1,7 @@
/* {{{ var object helpers */
#ifdef ZEND_ENGINE_2
-xc_vector_t objects; /* in calc only */
+xc_vector_t object_handles; /* in calc/restore only */
HashTable handle_to_index; /* in calc/store only */
-zend_object_handle *object_handles; /* in restore only */
#endif
const xc_entry_var_t *entry_var_src; /* in restore */
diff --git a/processor/var-helper.h b/processor/var-helper.h
index d2a01c8..957147d 100644
--- a/processor/var-helper.h
+++ b/processor/var-helper.h
@@ -3,15 +3,15 @@ static void xc_var_collect_object(xc_processor_t *processor, zend_object_handle
{
size_t next_index;
- if (!xc_vector_initialized(&processor->objects)) {
- xc_vector_init(zend_object, &processor->objects);
+ if (!xc_vector_initialized(&processor->object_handles)) {
+ xc_vector_init(zend_object, &processor->object_handles);
zend_hash_init(&processor->handle_to_index, 0, NULL, NULL, 0);
}
- next_index = xc_vector_size(&processor->objects);
+ next_index = xc_vector_size(&processor->object_handles);
if (_zend_hash_index_update_or_next_insert(&processor->handle_to_index, handle, (void *) &next_index, sizeof(next_index), NULL, HASH_ADD ZEND_FILE_LINE_CC) == SUCCESS) {
zend_object *object = zend_object_store_get_object_by_handle(handle TSRMLS_CC);
- xc_vector_push_back(&processor->objects, object);
+ xc_vector_push_back(&processor->object_handles, object);
}
}
/* }}} */
@@ -20,7 +20,7 @@ static size_t xc_var_store_handle(xc_processor_t *processor, zend_object_handle
size_t *index;
if (zend_hash_index_find(&processor->handle_to_index, handle, (void **) &index) != SUCCESS) {
- php_error_docref(NULL TSRMLS_CC, E_CORE_ERROR, "Internal error: handle %d not found in objects", handle);
+ php_error_docref(NULL TSRMLS_CC, E_CORE_ERROR, "Internal error: handle %d not found on store", handle);
return (size_t) -1;
}
@@ -29,7 +29,7 @@ static size_t xc_var_store_handle(xc_processor_t *processor, zend_object_handle
/* }}} */
static zend_object_handle xc_var_restore_handle(xc_processor_t *processor, size_t index TSRMLS_DC) /* {{{ */
{
- zend_object_handle handle = processor->object_handles[index];
+ zend_object_handle handle = xc_vector_data(zend_object_handle, &processor->object_handles)[index];
zend_objects_store_add_ref_by_handle(handle TSRMLS_CC);
return handle;
}