Skip to content

Commit

Permalink
Micro optimize Route.
Browse files Browse the repository at this point in the history
Calling empty() instead of a userland function is a teeny tiny bit
faster.
  • Loading branch information
markstory committed Jun 25, 2014
1 parent a4e6385 commit 3e5cb58
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Routing/Route/Route.php
Expand Up @@ -150,7 +150,7 @@ public function compiled() {
* @return array Returns a string regular expression of the compiled route.
*/
public function compile() {
if ($this->compiled()) {
if (!empty($this->compiledRoute)) {
return $this->_compiledRoute;
}
$this->_writeRoute();
Expand Down Expand Up @@ -259,7 +259,7 @@ public function getName() {
public function parse($url) {
$request = Router::getRequest(true) ?: Request::createFromGlobals();

if (!$this->compiled()) {
if (empty($this->_compiledRoute)) {
$this->compile();
}
list($url, $ext) = $this->_parseExtension($url);
Expand Down Expand Up @@ -399,7 +399,7 @@ protected function _parseArgs($args, $context) {
* @return mixed Either a string url for the parameters if they match or false.
*/
public function match(array $url, array $context = []) {
if (!$this->compiled()) {
if (empty($this->_compiledRoute)) {
$this->compile();
}
$defaults = $this->defaults;
Expand Down

0 comments on commit 3e5cb58

Please sign in to comment.