Преглед на файлове

Use $var[] = $a instead of array_push - 2x faster

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Morris Jobke преди 6 години
родител
ревизия
870fe20acc

+ 1 - 1
apps/files_versions/lib/Storage.php

@@ -566,7 +566,7 @@ class Storage {
 				$fileData = $file->getData();
 				$filePath = $dir . '/' . $fileData['name'];
 				if ($file['type'] === 'dir') {
-					array_push($dirs, $filePath);
+					$dirs[] = $filePath;
 				} else {
 					$versionsBegin = strrpos($filePath, '.v');
 					$relPathStart = strlen(self::VERSIONS_ROOT);

+ 1 - 1
apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php

@@ -86,7 +86,7 @@ class BackupCodeStorage {
 			$dbCode->setUsed(0);
 			$this->mapper->insert($dbCode);
 
-			array_push($result, $code);
+			$result[] = $code;
 		}
 
 		$this->publishEvent($user, 'codes_generated');

+ 2 - 2
lib/private/Activity/Manager.php

@@ -231,7 +231,7 @@ class Manager implements IManager {
 	 * @param \Closure $callable
 	 */
 	public function registerConsumer(\Closure $callable) {
-		array_push($this->consumersClosures, $callable);
+		$this->consumersClosures[] = $callable;
 		$this->consumers = [];
 	}
 
@@ -244,7 +244,7 @@ class Manager implements IManager {
 	 * @param \Closure $callable
 	 */
 	public function registerExtension(\Closure $callable) {
-		array_push($this->extensionsClosures, $callable);
+		$this->extensionsClosures[] = $callable;
 		$this->extensions = [];
 	}
 

+ 1 - 1
lib/private/AppFramework/DependencyInjection/DIContainer.php

@@ -335,7 +335,7 @@ class DIContainer extends SimpleContainer implements IAppContainer {
 	 * @return boolean|null
 	 */
 	public function registerMiddleWare($middleWare) {
-		array_push($this->middleWares, $middleWare);
+		$this->middleWares[] = $middleWare;
 	}
 
 	/**

+ 1 - 1
lib/private/AppFramework/Middleware/MiddlewareDispatcher.php

@@ -63,7 +63,7 @@ class MiddlewareDispatcher {
 	 * @param Middleware $middleWare the middleware which will be added
 	 */
 	public function registerMiddleware(Middleware $middleWare){
-		array_push($this->middlewares, $middleWare);
+		$this->middlewares[] = $middleWare;
 	}
 
 

+ 2 - 2
lib/private/Collaboration/Collaborators/GroupPlugin.php

@@ -102,13 +102,13 @@ class GroupPlugin implements ISearchPlugin {
 			// user id and if so, we add that to the exact match list
 			$group = $this->groupManager->get($search);
 			if ($group instanceof IGroup && (!$this->shareWithGroupOnly || in_array($group->getGID(), $userGroups))) {
-				array_push($result['exact'], [
+				$result['exact'][] = [
 					'label' => $group->getDisplayName(),
 					'value' => [
 						'shareType' => Share::SHARE_TYPE_GROUP,
 						'shareWith' => $group->getGID(),
 					],
-				]);
+				];
 			}
 		}
 

+ 2 - 2
lib/private/Collaboration/Collaborators/UserPlugin.php

@@ -128,13 +128,13 @@ class UserPlugin implements ISearchPlugin {
 				}
 
 				if ($addUser) {
-					array_push($result['exact'], [
+					$result['exact'][] = [
 						'label' => $user->getDisplayName(),
 						'value' => [
 							'shareType' => Share::SHARE_TYPE_USER,
 							'shareWith' => $user->getUID(),
 						],
-					]);
+					];
 				}
 			}
 		}