Skip to content

Commit

Permalink
RequestFactory: optimized script path detection performance
Browse files Browse the repository at this point in the history
  • Loading branch information
JanTvrdik committed Dec 18, 2014
1 parent e9dd988 commit 8851c4d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Http/RequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,16 @@ public function createHttpRequest()
$script = '/';
}

$path = strtolower($url->getPath()) . '/';
$script = strtolower($script) . '/';
$max = min(strlen($path), strlen($script));
for ($i = 0; $i < $max; $i++) {
if ($path[$i] !== $script[$i]) {
$path = $url->getPath();
$max = min(strlen($path), strlen($script)) - 1;
for ($i = 0, $j = 0; $i <= $max; $i++) {
if ($path[$i] !== $script[$i] && strcasecmp($path[$i], $script[$i])) {
break;
} elseif ($path[$i] === '/') {
$url->setScriptPath(substr($url->getPath(), 0, $i + 1));
} elseif ($path[$i] === '/' || $i === $max) {
$j = $i;
}
}
$url->setScriptPath(substr($path, 0, $j + 1));

// GET, POST, COOKIE
$useFilter = (!in_array(ini_get('filter.default'), array('', 'unsafe_raw')) || ini_get('filter.default_flags'));
Expand Down

0 comments on commit 8851c4d

Please sign in to comment.