-
Notifications
You must be signed in to change notification settings - Fork 29
Conversation
samsonasik
commented
Jul 8, 2018
- Is this related to quality assurance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @samsonasik
thanks a lot for your contribution. I just added a minor change - note. But nothing critical, I could do this on merge. If you are able to change this, I'd appreciate.
@@ -134,7 +134,7 @@ private function buildParametersCode(string $type) | |||
$tab = str_repeat(' ', $intention); | |||
$code = ''; | |||
|
|||
if (count($withOptions)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be imported with use function
for performance. You may actively do this, but don't worry, I can do this during the pull as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
truthy check is faster than count($var)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't make a difference with the current opcode optimisations in the language, but yes, a direct truth check is faster indeed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misread of the diff on my side never mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ocramius VLD opcodes for 7.1 show that count()
actually does function call, initializing function context is the most expensive op here:
line #* E I O op fetch ext return operands
-------------------------------------------------------------------------------------
if ($var) :
5 6 > JMPZ !0, ->8
6 7 > ECHO 1
if (count($var)) :
9 8 > INIT_FCALL 'count'
9 SEND_VAR !0
10 DO_ICALL $4
11 > JMPZ $4, ->13
10 12 > ECHO 2
if (! empty($var)) :
13 13 > ISSET_ISEMPTY_VAR 293601280 ~5 !0
14 BOOL_NOT ~6 ~5
15 > JMPZ ~6, ->17
14 16 > ECHO 3
Not that it really matters, it is optimized in 7.2
@samsonasik one note though: you keep sending these against |
@Ocramius rebased against develop and set target to develop |
@Ocramius right, thanks. |