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

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Morris Jobke 2018-01-25 22:36:03 +01:00
parent b9bbb894f8
commit 870fe20acc
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
7 changed files with 10 additions and 10 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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