Skip to content

Commit

Permalink
Remove count and range
Browse files Browse the repository at this point in the history
  • Loading branch information
Jurigag authored and sergeyklay committed Jul 2, 2018
1 parent e32b7c4 commit 9a4ea5b
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions phalcon/mvc/router.zep
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class Router implements InjectionAwareInterface, RouterInterface, EventsAwareInt

protected _keyRouteNames = [] { get, set };

protected _idRouteNames = [] { get, set };
protected _keyRouteIds = [] { get, set };

const URI_SOURCE_GET_URL = 0;

Expand Down Expand Up @@ -965,18 +965,15 @@ class Router implements InjectionAwareInterface, RouterInterface, EventsAwareInt
*/
public function getRouteById(var id) -> <RouteInterface> | boolean
{
var route, size, routeId, key;
var route, routeId, key;

if fetch key, this->_idRouteNames[id] {
if fetch key, this->_keyRouteIds[id] {
return this->_routes[key];
}

let size = count(this->_routes);

for key in range(0, size - 1) {
let route = this->_routes[key];
for key, route in this->_routes {
let routeId = route->getRouteId();
let this->_idRouteNames[routeId] = key;
let this->_keyRouteIds[routeId] = key;

if routeId == id {
return route;
Expand All @@ -996,15 +993,14 @@ class Router implements InjectionAwareInterface, RouterInterface, EventsAwareInt
return this->_routes[key];
}

let size = count(this->_routes);

for key in range(0, size - 1) {
let route = this->_routes[key];
for key, route in this->_routes {
let routeName = route->getName();
let this->_keyRouteNames[routeName] = key;
if !empty routeName {
let this->_keyRouteNames[routeName] = key;

if routeName == name {
return route;
if routeName == name {
return route;
}
}
}
return false;
Expand Down

0 comments on commit 9a4ea5b

Please sign in to comment.