summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-01-10 16:32:50 +0100
committerMorris Jobke <hey@morrisjobke.de>2015-01-10 16:32:50 +0100
commit8057bc6646765a5e70f1dd79a5576fca850c4582 (patch)
treebf7efbe8ac53b27eff3e34e697e0a16d10705763
parent74d1a9ea3d5526e98a3febd13653917a2970f9e0 (diff)
parent310424db5d57536edcc9238224415756a1c8a624 (diff)
downloadnextcloud-server-8057bc6646765a5e70f1dd79a5576fca850c4582.tar.gz
nextcloud-server-8057bc6646765a5e70f1dd79a5576fca850c4582.zip
Merge pull request #13236 from owncloud/use-isset-for-performance
Use isset() instead of strlen()
-rw-r--r--lib/private/files/view.php6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index f1c15e197d9..034c49a9059 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -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");
}
}