Skip to content
Permalink
Browse files

Minor optimizations in Router

  • Loading branch information...
markstory committed Jan 27, 2010
1 parent 57997e7 commit 2b353e90f83280abfb8a93f42e624bc1417af0be
Showing with 7 additions and 10 deletions.
  1. +7 −10 cake/libs/router.php
@@ -788,7 +788,7 @@ function url($url = null, $full = false) {
$prefixExists = (array_intersect_key($url, array_flip($self->__prefixes)));
foreach ($self->__prefixes as $prefix) {
if (!isset($url[$prefix]) && !empty($params[$prefix]) && !$prefixExists) {
if (!empty($params[$prefix]) && !$prefixExists) {
$url[$prefix] = true;
} elseif (isset($url[$prefix]) && !$url[$prefix]) {
unset($url[$prefix]);
@@ -812,7 +812,6 @@ function url($url = null, $full = false) {
if ($match = $self->routes[$i]->match($url)) {
$output = trim($match, '/');
$url = array();
break;
}
$url = $originalUrl;
@@ -1537,14 +1536,12 @@ function _writeUrl($params) {
$instance =& Router::getInstance();
$separator = $instance->named['separator'];
if (!empty($params['named'])) {
if (is_array($params['named'])) {
$named = array();
foreach ($params['named'] as $key => $value) {
$named[] = $key . $separator . $value;
}
$params['pass'] = $params['pass'] . '/' . implode('/', $named);;
if (!empty($params['named']) && is_array($params['named'])) {
$named = array();
foreach ($params['named'] as $key => $value) {
$named[] = $key . $separator . $value;
}
$params['pass'] = $params['pass'] . '/' . implode('/', $named);
}
$out = $this->template;
@@ -1554,7 +1551,7 @@ function _writeUrl($params) {
if (isset($params[$key])) {
$string = $params[$key];
} elseif (strpos($out, $key) != strlen($out) - strlen($key)) {
$key = $key . '/';
$key .= '/';
}
$search[] = ':' . $key;
$replace[] = $string;

0 comments on commit 2b353e9

Please sign in to comment.
You can’t perform that action at this time.