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

RFC: array_find #14108

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft

RFC: array_find #14108

wants to merge 9 commits into from

Conversation

joshuaruesweg
Copy link
Member

Copy link
Contributor

@morrisonlevi morrisonlevi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a quick look, have a few suggestions.

Comment on lines +6627 to +6629
if (negate_condition) {
retval_true = !retval_true;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be simplified to:

Suggested change
if (negate_condition) {
retval_true = !retval_true;
}
retval_true ^= negate_condition;

I believe this truth table matches both pieces of code to prove it:

retval_true negate_condition result
0 0 0
0 1 1
1 0 1
1 1 0

However, it is late for me, so sorry if I made a mistake.


ZVAL_COPY(&args[0], operand);

if (zend_call_function(&fci, &fci_cache) == SUCCESS) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would save this to a variable which we can use to clean up below, and also mark it as EXPECTED:

Suggested change
if (zend_call_function(&fci, &fci_cache) == SUCCESS) {
zend_result result = zend_call_function(&fci, &fci_cache);
if (EXPECTED(result == SUCCESS)) {

Comment on lines +6644 to +6653
} else {
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);
}
} else {
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);

return FAILURE;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This uses the suggestion of saving result to a variable to coalesce the dtor code:

Suggested change
} else {
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);
}
} else {
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);
return FAILURE;
}
}
}
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);
if (UNEXPECTED(result != SUCCESS)) {
return FAILURE;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants