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

Return Value Optimization #1046

Merged
merged 4 commits into from Aug 10, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Bug fixes
  • Loading branch information
sjinks committed Aug 10, 2013
commit a0427e1404fe78f82ecc87e4c67f6e709812868f
4 changes: 2 additions & 2 deletions ext/kernel/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,14 @@ extern int phalcon_fetch_parameters(int num_args TSRMLS_DC, int required_args, i
* Returns a zval in an object member
*/
#define RETURN_MEMBER(object, member_name) \
phalcon_return_property_quick(return_value, object, SL(member_name), zend_inline_hash_func(SS(member_name)) TSRMLS_CC); \
phalcon_return_property_quick(return_value, return_value_ptr, object, SL(member_name), zend_inline_hash_func(SS(member_name)) TSRMLS_CC); \
return;

/**
* Returns a zval in an object member (quick)
*/
#define RETURN_MEMBER_QUICK(object, member_name, key) \
phalcon_return_property_quick(return_value, object, SL(member_name), key TSRMLS_CC); \
phalcon_return_property_quick(return_value, return_value_ptr, object, SL(member_name), key TSRMLS_CC); \
return;

/** Return without change return_value */
Expand Down
18 changes: 9 additions & 9 deletions ext/kernel/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ zval** phalcon_fetch_property_this_quick(zval *object, char *property_name, unsi
/**
* Returns an object's member
*/
int phalcon_return_property_quick(zval *return_value, zval *object, char *property_name, unsigned int property_length, unsigned long key TSRMLS_DC) {
int phalcon_return_property_quick(zval *return_value, zval **return_value_ptr, zval *object, char *property_name, unsigned int property_length, unsigned long key TSRMLS_DC) {

zval **zv;
zend_object *zobj;
Expand All @@ -622,10 +622,10 @@ int phalcon_return_property_quick(zval *return_value, zval *object, char *proper

EG(scope) = old_scope;

if (EG(return_value_ptr_ptr)) {
zval_ptr_dtor(EG(return_value_ptr_ptr));
if (return_value_ptr) {
zval_ptr_dtor(return_value_ptr);
Z_ADDREF_PP(zv);
*EG(return_value_ptr_ptr) = *zv;
*return_value_ptr = *zv;
}
else {
ZVAL_ZVAL(return_value, *zv, 1, 0);
Expand Down Expand Up @@ -665,10 +665,10 @@ int phalcon_return_property_quick(zval *return_value, zval *object, char *proper
if (likely(!flag)) {
EG(scope) = old_scope;

if (EG(return_value_ptr_ptr)) {
zval_ptr_dtor(EG(return_value_ptr_ptr));
if (return_value_ptr) {
zval_ptr_dtor(return_value_ptr);
Z_ADDREF_PP(zv);
*EG(return_value_ptr_ptr) = *zv;
*return_value_ptr = *zv;
}
else {
ZVAL_ZVAL(return_value, *zv, 1, 0);
Expand All @@ -694,9 +694,9 @@ int phalcon_return_property_quick(zval *return_value, zval *object, char *proper
/**
* Returns an object's member
*/
int phalcon_return_property(zval *return_value, zval *object, char *property_name, unsigned int property_length TSRMLS_DC) {
int phalcon_return_property(zval *return_value, zval **return_value_ptr, zval *object, char *property_name, unsigned int property_length TSRMLS_DC) {

return phalcon_return_property_quick(return_value, object, property_name, property_length, zend_inline_hash_func(property_name, property_length + 1) TSRMLS_CC);
return phalcon_return_property_quick(return_value, return_value_ptr, object, property_name, property_length, zend_inline_hash_func(property_name, property_length + 1) TSRMLS_CC);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions ext/kernel/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ zval** phalcon_fetch_property_this(zval *object, char *property_name, unsigned i
zval** phalcon_fetch_property_this_quick(zval *object, char *property_name, unsigned int property_length, unsigned long key, int silent TSRMLS_DC);
int phalcon_read_property(zval **result, zval *object, char *property_name, unsigned int property_length, int silent TSRMLS_DC);
int phalcon_read_property_zval(zval **result, zval *object, zval *property, int silent TSRMLS_DC);
int phalcon_return_property(zval *return_value, zval *object, char *property_name, unsigned int property_length TSRMLS_DC);
int phalcon_return_property_quick(zval *return_value, zval *object, char *property_name, unsigned int property_length, unsigned long key TSRMLS_DC);
int phalcon_return_property(zval *return_value, zval **return_value_ptr, zval *object, char *property_name, unsigned int property_length TSRMLS_DC);
int phalcon_return_property_quick(zval *return_value, zval **return_value_ptr, zval *object, char *property_name, unsigned int property_length, unsigned long key TSRMLS_DC);

/** Updating properties */
extern int phalcon_update_property_this(zval *object, char *property_name, unsigned int property_length, zval *value TSRMLS_DC);
Expand Down