diff options
author | Lukas Reschke <lukas@owncloud.com> | 2014-10-23 23:27:15 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2014-10-24 12:27:53 +0200 |
commit | d060180140923ac054b252f0cbd821063a53f5b7 (patch) | |
tree | 59d53bb16be35960f493709d8409a75bc79be47e /lib/private | |
parent | 9739a25547e5f8f7500b0a962780cb9267b47cd1 (diff) | |
download | nextcloud-server-d060180140923ac054b252f0cbd821063a53f5b7.tar.gz nextcloud-server-d060180140923ac054b252f0cbd821063a53f5b7.zip |
Use function outside of loop
Otherwise the function is executed n times which is a lot of overhead
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/appframework/middleware/middlewaredispatcher.php | 5 | ||||
-rw-r--r-- | lib/private/arrayparser.php | 4 | ||||
-rw-r--r-- | lib/private/db/statementwrapper.php | 3 | ||||
-rw-r--r-- | lib/private/ocsclient.php | 5 | ||||
-rw-r--r-- | lib/private/vobject.php | 3 |
5 files changed, 13 insertions, 7 deletions
diff --git a/lib/private/appframework/middleware/middlewaredispatcher.php b/lib/private/appframework/middleware/middlewaredispatcher.php index dcb63a8e552..41eef4aedb9 100644 --- a/lib/private/appframework/middleware/middlewaredispatcher.php +++ b/lib/private/appframework/middleware/middlewaredispatcher.php @@ -82,8 +82,9 @@ class MiddlewareDispatcher { */ public function beforeController(Controller $controller, $methodName){ // we need to count so that we know which middlewares we have to ask in - // case theres an exception - for($i=0; $i<count($this->middlewares); $i++){ + // case there is an exception + $middlewareCount = count($this->middlewares); + for($i = 0; $i < $middlewareCount; $i++){ $this->middlewareCounter++; $middleware = $this->middlewares[$i]; $middleware->beforeController($controller, $methodName); diff --git a/lib/private/arrayparser.php b/lib/private/arrayparser.php index a5e1f6653fc..dab1817c2ed 100644 --- a/lib/private/arrayparser.php +++ b/lib/private/arrayparser.php @@ -182,7 +182,9 @@ class ArrayParser { if (substr($body, -1, 1) !== ',') { $body .= ','; } - for ($i = 0; $i < strlen($body); $i++) { + + $bodyLength = strlen($body); + for ($i = 0; $i < $bodyLength; $i++) { $char = substr($body, $i, 1); if ($char === '\\') { if ($escaped) { diff --git a/lib/private/db/statementwrapper.php b/lib/private/db/statementwrapper.php index 93fabc147ca..ad63de98e93 100644 --- a/lib/private/db/statementwrapper.php +++ b/lib/private/db/statementwrapper.php @@ -89,9 +89,10 @@ class OC_DB_StatementWrapper { $cArg = 0; $inSubstring = false; + $queryLength = strlen($query); // Create new query - for ($i = 0; $i < strlen ($query); $i++) { + for ($i = 0; $i < $queryLength; $i++) { if ($inSubstring == false) { // Defines when we should start inserting values if (substr ($query, $i, 9) == 'SUBSTRING') { diff --git a/lib/private/ocsclient.php b/lib/private/ocsclient.php index 8ceb43f4c1f..351027d8018 100644 --- a/lib/private/ocsclient.php +++ b/lib/private/ocsclient.php @@ -129,8 +129,9 @@ class OC_OCSClient{ $data = simplexml_load_string($xml); libxml_disable_entity_loader($loadEntities); - $tmp=$data->data->content; - for($i = 0; $i < count($tmp); $i++) { + $tmp = $data->data->content; + $tmpCount = count($tmp); + for($i = 0; $i < $tmpCount; $i++) { $app=array(); $app['id']=(string)$tmp[$i]->id; $app['name']=(string)$tmp[$i]->name; diff --git a/lib/private/vobject.php b/lib/private/vobject.php index 94e3470ff08..9d121c17d79 100644 --- a/lib/private/vobject.php +++ b/lib/private/vobject.php @@ -72,7 +72,8 @@ class OC_VObject{ */ public static function unescapeSemicolons($value) { $array = explode(';', $value); - for($i=0;$i<count($array);$i++) { + $arrayCount = count($array); + for($i = 0; $i < $arrayCount; $i++) { if(substr($array[$i], -2, 2)=="\\\\") { if(isset($array[$i+1])) { $array[$i] = substr($array[$i], 0, count($array[$i])-2).';'.$array[$i+1]; |