Skip to content

Commit

Permalink
Optimize DashedRoute and Inflector::variable().
Browse files Browse the repository at this point in the history
Reduce the number of function calls done for micro perf gains.
  • Loading branch information
markstory committed Jan 22, 2016
1 parent bc1ec25 commit 7fe3621
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions src/Routing/Route/DashedRoute.php
Expand Up @@ -65,11 +65,7 @@ public function parse($url)
return false;
}
if (!empty($params['controller'])) {
$params['controller'] = Inflector::camelize(str_replace(
'-',
'_',
$params['controller']
));
$params['controller'] = Inflector::camelize($params['controller'], '-');
}
if (!empty($params['plugin'])) {
$params['plugin'] = $this->_camelizePlugin($params['plugin']);
Expand Down
2 changes: 1 addition & 1 deletion src/Utility/Inflector.php
Expand Up @@ -720,7 +720,7 @@ public static function variable($string)
if ($result === false) {
$camelized = static::camelize(static::underscore($string));
$replace = strtolower(substr($camelized, 0, 1));
$result = preg_replace('/\\w/', $replace, $camelized, 1);
$result = $replace . substr($camelized, 1);
static::_cache(__FUNCTION__, $string, $result);
}

Expand Down

0 comments on commit 7fe3621

Please sign in to comment.