From 870fe20acc90cbfb89bf710f441d62f8bcf92f9d Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Thu, 25 Jan 2018 22:36:03 +0100 Subject: [PATCH] Use $var[] = $a instead of array_push - 2x faster Signed-off-by: Morris Jobke --- apps/files_versions/lib/Storage.php | 2 +- apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php | 2 +- lib/private/Activity/Manager.php | 4 ++-- lib/private/AppFramework/DependencyInjection/DIContainer.php | 2 +- lib/private/AppFramework/Middleware/MiddlewareDispatcher.php | 2 +- lib/private/Collaboration/Collaborators/GroupPlugin.php | 4 ++-- lib/private/Collaboration/Collaborators/UserPlugin.php | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php index 4c76c5340f..6b8a441f7b 100644 --- a/apps/files_versions/lib/Storage.php +++ b/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); diff --git a/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php b/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php index 84bf54d337..2fb5fe8a6c 100644 --- a/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php +++ b/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'); diff --git a/lib/private/Activity/Manager.php b/lib/private/Activity/Manager.php index 792dea4cff..1b64fa59a9 100644 --- a/lib/private/Activity/Manager.php +++ b/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 = []; } diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index 94c725f3fb..d9e82819d1 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/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; } /** diff --git a/lib/private/AppFramework/Middleware/MiddlewareDispatcher.php b/lib/private/AppFramework/Middleware/MiddlewareDispatcher.php index 306b8095a9..60d2ae8b5c 100644 --- a/lib/private/AppFramework/Middleware/MiddlewareDispatcher.php +++ b/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; } diff --git a/lib/private/Collaboration/Collaborators/GroupPlugin.php b/lib/private/Collaboration/Collaborators/GroupPlugin.php index 0b2b3d7102..b147d2d7b5 100644 --- a/lib/private/Collaboration/Collaborators/GroupPlugin.php +++ b/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(), ], - ]); + ]; } } diff --git a/lib/private/Collaboration/Collaborators/UserPlugin.php b/lib/private/Collaboration/Collaborators/UserPlugin.php index ad67770354..d2639249d5 100644 --- a/lib/private/Collaboration/Collaborators/UserPlugin.php +++ b/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(), ], - ]); + ]; } } }