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:
Michal Sniatala 2020-07-12 10:33:22 +02:00 committed by GitHub
commit 90a6b6f99f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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]);
}