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

PHALCON_INIT_NVAR(_PNULL) optimization #1220

Merged
merged 1 commit into from Sep 12, 2013
Merged

PHALCON_INIT_NVAR(_PNULL) optimization #1220

merged 1 commit into from Sep 12, 2013

Conversation

ghost
Copy link

@ghost ghost commented Sep 12, 2013

Replaces calls to

zval_ptr_dtor(&z);
PHALCON_ALLOC_ZVAL(z);

with

zval_dtor(z);
ZVAL_NULL(z);

when Z_REFCOUNT_P(z) == 1.

This:

  • makes sure that the new variable will not changes its location in memory (and thus PHALCON_INIT_NVAR() can be used after PHALCON_SEPARATE_PARAM() — this will make Image code more readable — @dreamsxin, please watch this thread!)
  • reduces the number of memory (re)allocations

When manual-unit.php is run under valgrind:

  • before: 1,994,062 allocs, 1,993,839 frees, 355,849,237 bytes allocated
  • after: 1,968,935 allocs, 1,968,712 frees, 355,062,535 bytes allocated

@dreamsxin
Copy link
Contributor

OK, I will merge this.

@dreamsxin dreamsxin mentioned this pull request Sep 12, 2013
phalcon pushed a commit that referenced this pull request Sep 12, 2013
PHALCON_INIT_NVAR(_PNULL) optimization
@phalcon phalcon merged commit 5eebbe6 into phalcon:1.3.0 Sep 12, 2013
@phalcon
Copy link
Collaborator

phalcon commented Sep 12, 2013

great!

@ghost ghost deleted the memory branch September 13, 2013 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants