[HttpFoundation][Sessions] Micro-optimization

This commit is contained in:
Drak 2012-07-23 10:52:09 +01:00
parent 9bf3cb4e97
commit ff273af546

View File

@ -39,14 +39,13 @@ class NativeFileSessionHandler extends NativeSessionHandler
$baseDir = $savePath;
if (strpos($baseDir, ';') !== false) {
$parts = explode(';', $baseDir);
if (count($parts) > 3) {
if ($count = substr_count($savePath, ';')) {
if ($count > 2) {
throw new \InvalidArgumentException(sprintf('Invalid argument $savePath \'%s\'', $savePath));
}
// characters after last ';' is the path
$baseDir = substr($baseDir, strrpos($baseDir, ';')+1, strlen($baseDir));
// characters after last ';' are the path
$baseDir = ltrim(strrchr($savePath, ';'), ';');
}
if ($baseDir && !is_dir($baseDir)) {