Skip to content
Permalink
Browse files

Micro optimize Route.

Calling empty() instead of a userland function is a teeny tiny bit
faster.
  • Loading branch information...
markstory committed Jun 21, 2014
1 parent a4e6385 commit 3e5cb58f803d59aa3d1028c9b328a2169191bf5d
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/Routing/Route/Route.php
@@ -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();
@@ -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);
@@ -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;

0 comments on commit 3e5cb58

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