php-transpiler icon indicating copy to clipboard operation
php-transpiler copied to clipboard

Add strlen to isset optimization

Open original-brownbear opened this issue 9 years ago • 0 comments

Checks like

if(strlen($string) > 5) 

can be optimized into a faster isset like

if(isset($string[5]))

This can easily be implemented. It needs a check to prevent this optimization when it comes to nested assignment like

if( ($length = strlen($string)) > 5) 

though. Obviously in this case the optimization makes no sense.

original-brownbear avatar Jan 03 '16 22:01 original-brownbear