Skip to content

Commit 23d4d69

Browse files
committed
perf(shares): avoid array_merge in loops
Signed-off-by: Salvatore Martire <[email protected]>
1 parent a371e51 commit 23d4d69

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

apps/dav/lib/Connector/Sabre/SharesPlugin.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,28 +98,28 @@ private function getShare(Node $node): array {
9898
];
9999

100100
foreach ($requestedShareTypes as $requestedShareType) {
101-
$result = array_merge($result, $this->shareManager->getSharesBy(
101+
$result[] = $this->shareManager->getSharesBy(
102102
$this->userId,
103103
$requestedShareType,
104104
$node,
105105
false,
106106
-1
107-
));
107+
);
108108

109109
// Also check for shares where the user is the recipient
110110
try {
111-
$result = array_merge($result, $this->shareManager->getSharedWith(
111+
$result[] = $this->shareManager->getSharedWith(
112112
$this->userId,
113113
$requestedShareType,
114114
$node,
115115
-1
116-
));
116+
);
117117
} catch (BackendError $e) {
118118
// ignore
119119
}
120120
}
121121

122-
return $result;
122+
return array_merge(...$result);
123123
}
124124

125125
/**

0 commit comments

Comments
 (0)