improve performance for searching with lots of threads

This commit is contained in:
David Edler 2022-05-24 21:14:23 +02:00 committed by GitHub
parent 1cd7493bf3
commit ca201c8dfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -918,15 +918,14 @@ class MailClient
$aSearchedUids = $this->GetUids($oParams->oCacher, $sSearch,
$oMessageCollection->FolderName, $oMessageCollection->FolderHash);
if ($bUseThreads && !$oParams->iThreadUid) {
$aUids = \array_filter($aUids, function($iUid) use ($aSearchedUids, $aAllThreads) {
if (\in_array($iUid, $aSearchedUids)) {
return true;
}
foreach ($aAllThreads as $aMap) {
if (\in_array($iUid, $aMap) && \array_intersect($aSearchedUids, $aMap)) {
return true;
$matchingThreadUids = [];
foreach ($aAllThreads as $aMap) {
if (\array_intersect($aSearchedUids, $aMap)) {
$matchingThreadUids = \array_merge($matchingThreadUids, $aMap);
}
}
}
$aUids = \array_filter($aUids, function($iUid) use ($aSearchedUids, $matchingThreadUids) {
return \in_array($iUid, $aSearchedUids) || \in_array($iUid, $matchingThreadUids);
});
} else {
$aUids = \array_filter($aUids, function($iUid) use ($aSearchedUids) {