1
0
Fork 0
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:
Jordi Boggiano 2012-08-23 19:16:23 +02:00
parent 9965f02951
commit e3b6bd781c
4 changed files with 64 additions and 1 deletions

View file

@ -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());