Skip to content

Commit

Permalink
Use $var[] = $a instead of array_push - 2x faster
Browse files Browse the repository at this point in the history
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
  • Loading branch information
MorrisJobke committed Jan 25, 2018
1 parent b9bbb89 commit 870fe20
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion apps/files_versions/lib/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ private static function getAllVersions($uid) {
$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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function createCodes(IUser $user, $number = 10) {
$dbCode->setUsed(0);
$this->mapper->insert($dbCode);

array_push($result, $code);
$result[] = $code;
}

$this->publishEvent($user, 'codes_generated');
Expand Down
4 changes: 2 additions & 2 deletions lib/private/Activity/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public function publishActivity($app, $subject, $subjectParams, $message, $messa
* @param \Closure $callable
*/
public function registerConsumer(\Closure $callable) {
array_push($this->consumersClosures, $callable);
$this->consumersClosures[] = $callable;
$this->consumers = [];
}

Expand All @@ -244,7 +244,7 @@ public function registerConsumer(\Closure $callable) {
* @param \Closure $callable
*/
public function registerExtension(\Closure $callable) {
array_push($this->extensionsClosures, $callable);
$this->extensionsClosures[] = $callable;
$this->extensions = [];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public function getServer()
* @return boolean|null
*/
public function registerMiddleWare($middleWare) {
array_push($this->middleWares, $middleWare);
$this->middleWares[] = $middleWare;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function __construct(){
* @param Middleware $middleWare the middleware which will be added
*/
public function registerMiddleware(Middleware $middleWare){
array_push($this->middlewares, $middleWare);
$this->middlewares[] = $middleWare;
}


Expand Down
4 changes: 2 additions & 2 deletions lib/private/Collaboration/Collaborators/GroupPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
// 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(),
],
]);
];
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/private/Collaboration/Collaborators/UserPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
}

if ($addUser) {
array_push($result['exact'], [
$result['exact'][] = [
'label' => $user->getDisplayName(),
'value' => [
'shareType' => Share::SHARE_TYPE_USER,
'shareWith' => $user->getUID(),
],
]);
];
}
}
}
Expand Down

0 comments on commit 870fe20

Please sign in to comment.