1
0
Fork 0

Optimize name only search with preg_grep, refs #10326

pull/10331/head
Jordi Boggiano 2021-12-03 14:54:17 +01:00
parent 7c8267f57c
commit 128a2648fb
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 4 additions and 4 deletions

View File

@ -492,10 +492,10 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
$results = array();
$regex = '{(?:'.implode('|', preg_split('{\s+}', $query)).')}i';
foreach ($this->getPackageNames() as $name) {
if (preg_match($regex, $name)) {
$results[] = array('name' => $name, 'description' => '');
}
$packageNames = $this->getPackageNames();
foreach (preg_grep($regex, $packageNames) as $name) {
$results2[] = array('name' => $name, 'description' => '');
}
return $results;