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

Read/modify/update optimization on properties #848

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 5 additions & 13 deletions ext/mvc/router/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ PHALCON_INIT_CLASS(Phalcon_Mvc_Router_Route){
PHP_METHOD(Phalcon_Mvc_Router_Route, __construct){

zval *pattern, *paths = NULL, *http_methods = NULL, *unique_id = NULL;
zval *route_id = NULL, *one, *next_id;
zval *route_id = NULL;

PHALCON_MM_GROW();

Expand Down Expand Up @@ -112,22 +112,14 @@ PHP_METHOD(Phalcon_Mvc_Router_Route, __construct){
PHALCON_OBS_VAR(unique_id);
phalcon_read_static_property(&unique_id, SL("phalcon\\mvc\\router\\route"), SL("_uniqueId") TSRMLS_CC);
if (Z_TYPE_P(unique_id) == IS_NULL) {
PHALCON_INIT_NVAR(unique_id);
ZVAL_LONG(unique_id, 0);
ZVAL_LONG(unique_id, 0); /* This updates the value of the static property as well */
}

/**
* TODO: Add a function that increase static members
*/
PHALCON_CPY_WRT(route_id, unique_id);
PHALCON_CPY_WRT_CTOR(route_id, unique_id); /* route_id is now separated from unique_id */
phalcon_update_property_this(this_ptr, SL("_id"), route_id TSRMLS_CC);

PHALCON_INIT_VAR(one);
ZVAL_LONG(one, 1);

PHALCON_INIT_VAR(next_id);
phalcon_add_function(next_id, unique_id, one TSRMLS_CC);
phalcon_update_static_property(SL("phalcon\\mvc\\router\\route"), SL("_uniqueId"), next_id TSRMLS_CC);
/* increment_function() will increment the value of the statis property as well */
increment_function(unique_id);

PHALCON_MM_RESTORE();
}
Expand Down