#752: should not use "substr($str, 0, 1)" but "$str[0]"
-------------------------+--------------------------------------------------
Reporter: MugeSo | Owner: david
Type: enhancement | Status: closed
Priority: normal | Milestone: 0.11.2
Component: _OTHER_ | Version: 0.11.0
Severity: normal | Resolution: wontfix
Keywords: | Has_patch: 0
-------------------------+--------------------------------------------------
Comment (by MugeSo):
>So we have to add a strlen() check, too.
i use isset() and benchmark again :)
{{{
[EMAIL PROTECTED] senna]$ time php -r '$str="abaed"; $token="a"; for($i=0; $i <
1000000; $i++){ isset($str[0]) && $str[0] === $token;}'
real 0m1.959s
user 0m1.940s
sys 0m0.020s
[EMAIL PROTECTED] senna]$ time php -r '$str=5; $token="a"; for($i=0; $i <
1000000; $i++){ isset($str[0]) && $str[0] === $token;}'
real 0m0.969s
user 0m0.950s
sys 0m0.020s
}}}
but, this code accepts $str=array($token).
--
Ticket URL: <http://trac.agavi.org/ticket/752#comment:4>
Agavi <http://www.agavi.org/>
An MVC Framework for PHP5
_______________________________________________
Agavi Tickets Mailing List
[email protected]
http://lists.agavi.org/mailman/listinfo/tickets