Ticket #752 (closed enhancement: wontfix)
should not use "substr($str, 0, 1)" but "$str[0]"
| Reported by: | MugeSo | Owned by: | david |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.11.2 |
| Component: | _OTHER_ | Version: | 0.11.0 |
| Severity: | normal | Keywords: | |
| Cc: | Patch attached: | no |
Description
In src/validator/AgaviDependencyManager.class.php, src/controller/AgaviController.class.php and src/routing/AgaviRouting.class.php, to retrive the first charactor of a string, substr function is used. However, in this case, []operator is better.
benchmark result:
[senna@vine senna]$ time php -r '$str="aaaaa"; for($i=0; $i < 1000000; $i++){ substr($str, 0, 1) == "a";}'
real 0m3.345s
user 0m3.320s
sys 0m0.020s
[senna@vine senna]$ time php -r '$str="aaaaa"; for($i=0; $i < 1000000; $i++){ $str[0] == "a";}'
real 0m2.012s
user 0m1.990s
sys 0m0.020s
[senna@vine senna]$ time php -r '$str="aaaaa"; for($i=0; $i < 1000000; $i++){ $str[0];}'
real 0m0.853s
user 0m0.850s
sys 0m0.010s
[senna@vine senna]$ time php -r '$str="aaaaa"; for($i=0; $i < 1000000; $i++){ substr($str, 0, 1);}'
real 0m2.585s
user 0m2.570s
sys 0m0.010s
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

