mirror of
https://github.com/composer/composer
synced 2025-05-10 17:12:51 +00:00
Add RepositoryInterface::filterPackages to stream ops on lists
This cuts down on memory usage and also speeds up the search command to a third of its previous time
This commit is contained in:
parent
9965f02951
commit
e3b6bd781c
4 changed files with 64 additions and 1 deletions
|
@ -112,6 +112,20 @@ class ArrayRepository implements RepositoryInterface
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function filterPackages($callback, $class = 'Composer\Package\Package')
|
||||
{
|
||||
foreach ($this->getPackages() as $package) {
|
||||
if (false === $callback($package)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function createAliasPackage(PackageInterface $package, $alias = null, $prettyAlias = null)
|
||||
{
|
||||
return new AliasPackage($package, $alias ?: $package->getAlias(), $prettyAlias ?: $package->getPrettyAlias());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue