Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize array functions #1972

Merged
merged 1 commit into from Feb 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ext/acl/adapter/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ PHP_METHOD(Phalcon_Acl_Adapter_Memory, __construct){

PHALCON_INIT_VAR(resources_names);
array_init_size(resources_names, 1);
phalcon_array_update_string(&resources_names, SL("*"), &PHALCON_GLOBAL(z_true), PH_COPY);
phalcon_array_update_string(&resources_names, SL("*"), PHALCON_GLOBAL(z_true), PH_COPY);
phalcon_update_property_this(this_ptr, SL("_resourcesNames"), resources_names TSRMLS_CC);

PHALCON_INIT_VAR(access_list);
array_init_size(access_list, 1);
phalcon_array_update_string(&access_list, SL("*!*"), &PHALCON_GLOBAL(z_true), PH_COPY);
phalcon_array_update_string(&access_list, SL("*!*"), PHALCON_GLOBAL(z_true), PH_COPY);
phalcon_update_property_this(this_ptr, SL("_accessList"), access_list TSRMLS_CC);

PHALCON_MM_RESTORE();
Expand Down Expand Up @@ -288,7 +288,7 @@ PHP_METHOD(Phalcon_Acl_Adapter_Memory, addInherit){

PHALCON_OBS_VAR(_roleInherits);
phalcon_read_property_this(&_roleInherits, this_ptr, SL("_roleInherits"), PH_NOISY_CC);
phalcon_array_update_append_multi_2(&_roleInherits, role_name, role_inherit_name, 0);
phalcon_array_append_multi_2(&_roleInherits, role_name, role_inherit_name, 0);
phalcon_update_property_this(this_ptr, SL("_roleInherits"), _roleInherits TSRMLS_CC);
RETURN_MM_TRUE;
}
Expand Down
4 changes: 2 additions & 2 deletions ext/annotations/annotation.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ PHP_METHOD(Phalcon_Annotations_Annotation, __construct){
PHALCON_INIT_NVAR(resolved_argument);
phalcon_call_method_p1(resolved_argument, this_ptr, "getexpression", expr);
if (phalcon_array_isset_string_fetch(&n, argument, SS("name"))) {
phalcon_array_update_zval(&arguments, n, &resolved_argument, PH_COPY);
phalcon_array_update_zval(&arguments, n, resolved_argument, PH_COPY);
} else {
phalcon_array_append(&arguments, resolved_argument, 0);
}
Expand Down Expand Up @@ -241,7 +241,7 @@ PHP_METHOD(Phalcon_Annotations_Annotation, getExpression){
PHALCON_INIT_NVAR(resolved_item);
phalcon_call_method_p1(resolved_item, this_ptr, "getexpression", expr);
if (phalcon_array_isset_string_fetch(&name, item, SS("name"))) {
phalcon_array_update_zval(&return_value, name, &resolved_item, PH_COPY);
phalcon_array_update_zval(&return_value, name, resolved_item, PH_COPY);
} else {
phalcon_array_append(&return_value, resolved_item, 0);
}
Expand Down
6 changes: 3 additions & 3 deletions ext/annotations/reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ PHP_METHOD(Phalcon_Annotations_Reader, parse){
RETURN_MM_ON_FAILURE(phannot_parse_annotations(class_annotations, cmt, cmt_len, file, line TSRMLS_CC));

if (Z_TYPE_P(class_annotations) == IS_ARRAY) {
phalcon_array_update_string(&annotations, SL("class"), &class_annotations, PH_COPY);
phalcon_array_update_string(&annotations, SL("class"), class_annotations, PH_COPY);
}
}
}
Expand Down Expand Up @@ -157,7 +157,7 @@ PHP_METHOD(Phalcon_Annotations_Reader, parse){
}

if (zend_hash_num_elements(Z_ARRVAL_P(annotations_properties))) {
phalcon_array_update_string(&annotations, SL("properties"), &annotations_properties, PH_COPY);
phalcon_array_update_string(&annotations, SL("properties"), annotations_properties, PH_COPY);
}
}
}
Expand Down Expand Up @@ -201,7 +201,7 @@ PHP_METHOD(Phalcon_Annotations_Reader, parse){
}

if (zend_hash_num_elements(Z_ARRVAL_P(annotations_methods))) {
phalcon_array_update_string(&annotations, SL("methods"), &annotations_methods, PH_COPY);
phalcon_array_update_string(&annotations, SL("methods"), annotations_methods, PH_COPY);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions ext/annotations/reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ PHP_METHOD(Phalcon_Annotations_Reflection, getMethodsAnnotations){
object_init_ex(collection, phalcon_annotations_collection_ce);
phalcon_call_method_p1_noret(collection, "__construct", reflection_method);

phalcon_array_update_zval(&return_value, method_name, &collection, PH_COPY);
phalcon_array_update_zval(&return_value, method_name, collection, PH_COPY);

zend_hash_move_forward_ex(ah0, &hp0);
}
Expand Down Expand Up @@ -227,7 +227,7 @@ PHP_METHOD(Phalcon_Annotations_Reflection, getPropertiesAnnotations){
object_init_ex(collection, phalcon_annotations_collection_ce);
phalcon_call_method_p1_noret(collection, "__construct", reflection_property);

phalcon_array_update_zval(&return_value, property, &collection, PH_COPY);
phalcon_array_update_zval(&return_value, property, collection, PH_COPY);

zend_hash_move_forward_ex(ah0, &hp0);
}
Expand Down
6 changes: 3 additions & 3 deletions ext/assets/manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ PHP_METHOD(Phalcon_Assets_Manager, output){
PHALCON_INIT_NVAR(parameters);
array_init_size(parameters, 2);
if (Z_TYPE_P(attributes) == IS_ARRAY) {
phalcon_array_update_long(&attributes, 0, &prefixed_path, PH_COPY | PH_SEPARATE);
phalcon_array_update_long(&attributes, 0, prefixed_path, PH_COPY | PH_SEPARATE);

phalcon_array_append(&parameters, attributes, 0);
} else {
Expand Down Expand Up @@ -940,7 +940,7 @@ PHP_METHOD(Phalcon_Assets_Manager, output){
PHALCON_INIT_NVAR(parameters);
array_init_size(parameters, 2);
if (Z_TYPE_P(attributes) == IS_ARRAY) {
phalcon_array_update_long(&attributes, 0, &prefixed_path, PH_COPY | PH_SEPARATE);
phalcon_array_update_long(&attributes, 0, prefixed_path, PH_COPY | PH_SEPARATE);

phalcon_array_append(&parameters, attributes, 0);
} else {
Expand Down Expand Up @@ -1004,7 +1004,7 @@ PHP_METHOD(Phalcon_Assets_Manager, output){
PHALCON_INIT_NVAR(parameters);
array_init_size(parameters, 2);
if (Z_TYPE_P(attributes) == IS_ARRAY) {
phalcon_array_update_long(&attributes, 0, &prefixed_path, PH_COPY | PH_SEPARATE);
phalcon_array_update_long(&attributes, 0, prefixed_path, PH_COPY | PH_SEPARATE);

phalcon_array_append(&parameters, attributes, 0);
} else {
Expand Down
4 changes: 2 additions & 2 deletions ext/cache/backend/libmemcached.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Libmemcached, __construct){

phalcon_array_append(&servers, server, 0);

phalcon_array_update_string(&options, SL("servers"), &servers, PH_COPY);
phalcon_array_update_string(&options, SL("servers"), servers, PH_COPY);
}

if (!phalcon_array_isset_string(options, SS("statsKey"))) {
Expand Down Expand Up @@ -371,7 +371,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Libmemcached, save){
}

if (!phalcon_array_isset(keys, last_key)) {
phalcon_array_update_zval(&keys, last_key, &ttl, PH_COPY);
phalcon_array_update_zval(&keys, last_key, ttl, PH_COPY);
phalcon_call_method_p2_noret(memcache, "set", special_key, keys);
}

Expand Down
2 changes: 1 addition & 1 deletion ext/cache/backend/memcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Memcache, save){
}

if (!phalcon_array_isset(keys, last_key)) {
phalcon_array_update_zval(&keys, last_key, &ttl, PH_COPY);
phalcon_array_update_zval(&keys, last_key, ttl, PH_COPY);
phalcon_call_method_p2_noret(memcache, "set", special_key, keys);
}

Expand Down
32 changes: 16 additions & 16 deletions ext/cache/backend/mongo.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Mongo, get){

PHALCON_INIT_VAR(conditions);
array_init_size(conditions, 2);
phalcon_array_update_string(&conditions, SL("key"), &prefixed_key, PH_COPY);
phalcon_array_update_string(&conditions, SL("key"), prefixed_key, PH_COPY);

MAKE_STD_ZVAL(time_condition);
array_init_size(time_condition, 1);
Expand Down Expand Up @@ -354,29 +354,29 @@ PHP_METHOD(Phalcon_Cache_Backend_Mongo, save){

PHALCON_INIT_VAR(conditions);
array_init_size(conditions, 1);
phalcon_array_update_string(&conditions, SL("key"), &last_key, PH_COPY);
phalcon_array_update_string(&conditions, SL("key"), last_key, PH_COPY);

PHALCON_OBS_VAR(document);
phalcon_call_method_p1_ex(document, &document, collection, "findone", conditions);

if (Z_TYPE_P(document) == IS_ARRAY) {
phalcon_array_update_string(&document, SL("time"), &timestamp, PH_COPY);
phalcon_array_update_string(&document, SL("time"), timestamp, PH_COPY);
if (prepared_content) {
phalcon_array_update_string(&document, SL("data"), &prepared_content, PH_COPY);
phalcon_array_update_string(&document, SL("data"), prepared_content, PH_COPY);
} else {
phalcon_array_update_string(&document, SL("data"), &cached_content, PH_COPY);
phalcon_array_update_string(&document, SL("data"), cached_content, PH_COPY);
}
phalcon_call_method_p1_noret(collection, "save", document);
} else {
PHALCON_INIT_VAR(data);
array_init_size(data, 3);
phalcon_array_update_string(&data, SL("key"), &last_key, PH_COPY);
phalcon_array_update_string(&data, SL("time"), &timestamp, PH_COPY);
phalcon_array_update_string(&data, SL("key"), last_key, PH_COPY);
phalcon_array_update_string(&data, SL("time"), timestamp, PH_COPY);

if (prepared_content) {
phalcon_array_update_string(&data, SL("data"), &prepared_content, PH_COPY);
phalcon_array_update_string(&data, SL("data"), prepared_content, PH_COPY);
} else {
phalcon_array_update_string(&data, SL("data"), &cached_content, PH_COPY);
phalcon_array_update_string(&data, SL("data"), cached_content, PH_COPY);
}

phalcon_call_method_p1_noret(collection, "save", data);
Expand Down Expand Up @@ -423,7 +423,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Mongo, delete){

PHALCON_INIT_VAR(conditions);
array_init_size(conditions, 1);
phalcon_array_update_string(&conditions, SL("key"), &prefixed_key, PH_COPY);
phalcon_array_update_string(&conditions, SL("key"), prefixed_key, PH_COPY);
phalcon_call_method_p1_noret(collection, "remove", conditions);

if ((php_rand(TSRMLS_C) % 100) == 0) {
Expand Down Expand Up @@ -472,13 +472,13 @@ PHP_METHOD(Phalcon_Cache_Backend_Mongo, queryKeys){
assert(phalcon_has_constructor(regex TSRMLS_CC));
phalcon_call_method_p1_noret(regex, "__construct", pattern);

phalcon_array_update_string(&conditions, SL("key"), &regex, PH_COPY);
phalcon_array_update_string(&conditions, SL("key"), regex, PH_COPY);
}

MAKE_STD_ZVAL(time_condition);
array_init_size(time_condition, 1);
add_assoc_long_ex(time_condition, SS("$gt"), (long int)time(NULL));
phalcon_array_update_string(&conditions, SL("time"), &time_condition, 0);
phalcon_array_update_string(&conditions, SL("time"), time_condition, 0);

PHALCON_OBS_VAR(documents);
phalcon_call_method_p2_ex(documents, &documents, collection, "find", conditions, fields);
Expand Down Expand Up @@ -537,12 +537,12 @@ PHP_METHOD(Phalcon_Cache_Backend_Mongo, exists){

PHALCON_INIT_VAR(conditions);
array_init_size(conditions, 2);
phalcon_array_update_string(&conditions, SL("key"), &last_key, PH_COPY);
phalcon_array_update_string(&conditions, SL("key"), last_key, PH_COPY);

MAKE_STD_ZVAL(time_condition);
array_init_size(time_condition, 1);
add_assoc_long_ex(time_condition, SS("$gt"), (long int)time(NULL));
phalcon_array_update_string(&conditions, SL("time"), &time_condition, 0);
phalcon_array_update_string(&conditions, SL("time"), time_condition, 0);

PHALCON_OBS_VAR(number);
phalcon_call_method_p1_ex(number, &number, collection, "count", conditions);
Expand Down Expand Up @@ -626,7 +626,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Mongo, increment){

PHALCON_INIT_VAR(conditions);
array_init_size(conditions, 1);
phalcon_array_update_string(&conditions, SL("key"), &prefixed_key, PH_COPY | PH_SEPARATE);
phalcon_array_update_string(&conditions, SL("key"), prefixed_key, PH_COPY);

PHALCON_INIT_VAR(document);
phalcon_call_method_p1(document, collection, "findone", conditions);
Expand Down Expand Up @@ -741,7 +741,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Mongo, decrement){

PHALCON_INIT_VAR(conditions);
array_init_size(conditions, 1);
phalcon_array_update_string(&conditions, SL("key"), &prefixed_key, PH_COPY | PH_SEPARATE);
phalcon_array_update_string(&conditions, SL("key"), prefixed_key, PH_COPY);

PHALCON_INIT_VAR(document);
phalcon_call_method_p1(document, collection, "findone", conditions);
Expand Down
2 changes: 1 addition & 1 deletion ext/cache/backend/xcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Xcache, save){
}

z_zero = PHALCON_GLOBAL(z_zero);
phalcon_array_update_zval(&keys, last_key, &ttl, PH_COPY);
phalcon_array_update_zval(&keys, last_key, ttl, PH_COPY);
PHALCON_CALL_FUNCTION_NORET("xcache_set", special_key, keys, z_zero);
}

Expand Down
2 changes: 1 addition & 1 deletion ext/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ PHP_METHOD(Phalcon_Config, toArray){
if (Z_TYPE_PP(value) == IS_OBJECT && phalcon_method_exists_ex(*value, SS("toarray") TSRMLS_CC) == SUCCESS) {
array_value = NULL;
if (SUCCESS == phalcon_call_method_params(array_value, &array_value, *value, SL("toarray"), zend_inline_hash_func(SS("toarray")) TSRMLS_CC, 0)) {
phalcon_array_update_zval(&return_value, &key, &array_value, 0);
phalcon_array_update_zval(&return_value, &key, array_value, 0);
}
}
}
Expand Down
Loading