mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Merge pull request #3281 from samsonasik/optimize-route-collection
optimize RouteCollection : use foreach instead of for with count when possible
This commit is contained in:
commit
90a6b6f99f
@ -831,10 +831,9 @@ class RouteCollection implements RouteCollectionInterface
|
||||
if (isset($options['except']))
|
||||
{
|
||||
$options['except'] = is_array($options['except']) ? $options['except'] : explode(',', $options['except']);
|
||||
$c = count($methods);
|
||||
for ($i = 0; $i < $c; $i ++)
|
||||
foreach ($methods as $i => $method)
|
||||
{
|
||||
if (in_array($methods[$i], $options['except']))
|
||||
if (in_array($method, $options['except']))
|
||||
{
|
||||
unset($methods[$i]);
|
||||
}
|
||||
@ -946,10 +945,9 @@ class RouteCollection implements RouteCollectionInterface
|
||||
if (isset($options['except']))
|
||||
{
|
||||
$options['except'] = is_array($options['except']) ? $options['except'] : explode(',', $options['except']);
|
||||
$c = count($methods);
|
||||
for ($i = 0; $i < $c; $i ++)
|
||||
foreach ($methods as $i => $method)
|
||||
{
|
||||
if (in_array($methods[$i], $options['except']))
|
||||
if (in_array($method, $options['except']))
|
||||
{
|
||||
unset($methods[$i]);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user