Skip to content

Commit

Permalink
Merge pull request #13236 from owncloud/use-isset-for-performance
Browse files Browse the repository at this point in the history
Use isset() instead of strlen()
  • Loading branch information
MorrisJobke committed Jan 10, 2015
2 parents 74d1a9e + 310424d commit 8057bc6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/private/files/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -1278,8 +1278,10 @@ public function getPath($id) {

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");
}
}
Expand Down

0 comments on commit 8057bc6

Please sign in to comment.