Merge pull request #13236 from owncloud/use-isset-for-performance

Use isset() instead of strlen()
This commit is contained in:
Morris Jobke 2015-01-10 16:32:50 +01:00
commit 8057bc6646
1 changed files with 4 additions and 2 deletions

View File

@ -1278,8 +1278,10 @@ class View {
private function assertPathLength($path) {
$maxLen = min(PHP_MAXPATHLEN, 4000);
$pathLen = strlen($path);
if ($pathLen > $maxLen) {
// Check for the string length - performed using isset() instead of strlen()
// because isset() is about 5x-40x faster.
if(isset($path[$maxLen])) {
$pathLen = strlen($path);
throw new \OCP\Files\InvalidPathException("Path length($pathLen) exceeds max path length($maxLen): $path");
}
}