Add memoization to parseConstraints, saves some (6-7% here) RAM and marginal CPU time
parent
cdea645eab
commit
c9436438ff
|
@ -20,7 +20,7 @@ use Composer\Repository\CompositeRepository;
|
|||
use Composer\Repository\PlatformRepository;
|
||||
use Composer\Plugin\CommandEvent;
|
||||
use Composer\Plugin\PluginEvents;
|
||||
use Composer\Semver\VersionParser;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
|
|
@ -20,7 +20,7 @@ use Composer\Factory;
|
|||
use Composer\Installer;
|
||||
use Composer\Json\JsonFile;
|
||||
use Composer\Json\JsonManipulator;
|
||||
use Composer\Semver\VersionParser;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
use Composer\Plugin\CommandEvent;
|
||||
use Composer\Plugin\PluginEvents;
|
||||
use Composer\Repository\CompositeRepository;
|
||||
|
|
|
@ -16,7 +16,7 @@ use Composer\DependencyResolver\Pool;
|
|||
use Composer\DependencyResolver\DefaultPolicy;
|
||||
use Composer\Factory;
|
||||
use Composer\Package\CompletePackageInterface;
|
||||
use Composer\Semver\VersionParser;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
use Composer\Plugin\CommandEvent;
|
||||
use Composer\Plugin\PluginEvents;
|
||||
use Composer\Package\PackageInterface;
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Composer\DependencyResolver;
|
|||
|
||||
use Composer\Package\BasePackage;
|
||||
use Composer\Package\AliasPackage;
|
||||
use Composer\Semver\VersionParser;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
use Composer\Semver\Constraint\ConstraintInterface;
|
||||
use Composer\Semver\Constraint\Constraint;
|
||||
use Composer\Semver\Constraint\EmptyConstraint;
|
||||
|
|
|
@ -27,7 +27,7 @@ use Composer\Util\Silencer;
|
|||
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
||||
use Composer\EventDispatcher\EventDispatcher;
|
||||
use Composer\Autoload\AutoloadGenerator;
|
||||
use Composer\Semver\VersionParser;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
use Composer\Downloader\TransportException;
|
||||
use Seld\JsonLint\JsonParser;
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
namespace Composer\Package;
|
||||
|
||||
use Composer\Semver\Constraint\Constraint;
|
||||
use Composer\Semver\VersionParser;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
|
||||
/**
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
|
|
|
@ -17,7 +17,7 @@ use Composer\Package\AliasPackage;
|
|||
use Composer\Package\Link;
|
||||
use Composer\Package\RootAliasPackage;
|
||||
use Composer\Package\RootPackageInterface;
|
||||
use Composer\Semver\VersionParser;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
|
||||
/**
|
||||
* @author Konstantin Kudryashiv <ever.zet@gmail.com>
|
||||
|
|
|
@ -18,7 +18,7 @@ use Composer\Package\AliasPackage;
|
|||
use Composer\Config;
|
||||
use Composer\Factory;
|
||||
use Composer\Package\Version\VersionGuesser;
|
||||
use Composer\Semver\VersionParser;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
use Composer\Repository\RepositoryManager;
|
||||
use Composer\Util\ProcessExecutor;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Composer\Package\Loader;
|
|||
use Composer\Package;
|
||||
use Composer\Package\BasePackage;
|
||||
use Composer\Semver\Constraint\Constraint;
|
||||
use Composer\Semver\VersionParser;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
use Composer\Repository\PlatformRepository;
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
namespace Composer\Package;
|
||||
|
||||
use Composer\Semver\VersionParser;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
use Composer\Util\ComposerMirror;
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Composer\Package\Version;
|
|||
use Composer\Config;
|
||||
use Composer\Repository\Vcs\HgDriver;
|
||||
use Composer\IO\NullIO;
|
||||
use Composer\Semver\VersionParser as SemverVersionParser;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
use Composer\Util\Git as GitUtil;
|
||||
use Composer\Util\ProcessExecutor;
|
||||
use Composer\Util\Svn as SvnUtil;
|
||||
|
@ -39,7 +39,7 @@ class VersionGuesser
|
|||
private $process;
|
||||
|
||||
/**
|
||||
* @var SemverVersionParser
|
||||
* @var VersionParser
|
||||
*/
|
||||
private $versionParser;
|
||||
|
||||
|
@ -48,7 +48,7 @@ class VersionGuesser
|
|||
* @param ProcessExecutor $process
|
||||
* @param VersionParser $versionParser
|
||||
*/
|
||||
public function __construct(Config $config, ProcessExecutor $process, SemverVersionParser $versionParser)
|
||||
public function __construct(Config $config, ProcessExecutor $process, VersionParser $versionParser)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->process = $process;
|
||||
|
|
|
@ -16,6 +16,20 @@ use Composer\Semver\VersionParser as SemverVersionParser;
|
|||
|
||||
class VersionParser extends SemverVersionParser
|
||||
{
|
||||
private static $constraints = array();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function parseConstraints($constraints)
|
||||
{
|
||||
if (!isset(self::$constraints[$constraints])) {
|
||||
self::$constraints[$constraints] = parent::parseConstraints($constraints);
|
||||
}
|
||||
|
||||
return self::$constraints[$constraints];
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses an array of strings representing package/version pairs.
|
||||
*
|
||||
|
|
|
@ -17,7 +17,7 @@ use Composer\Package\BasePackage;
|
|||
use Composer\Package\PackageInterface;
|
||||
use Composer\Package\Loader\ArrayLoader;
|
||||
use Composer\Package\Dumper\ArrayDumper;
|
||||
use Composer\Semver\VersionParser as SemverVersionParser;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
use Composer\Semver\Semver;
|
||||
use Composer\Semver\Constraint\Constraint;
|
||||
|
||||
|
@ -160,7 +160,7 @@ class VersionSelector
|
|||
private function getParser()
|
||||
{
|
||||
if ($this->parser === null) {
|
||||
$this->parser = new SemverVersionParser();
|
||||
$this->parser = new VersionParser();
|
||||
}
|
||||
|
||||
return $this->parser;
|
||||
|
|
|
@ -16,7 +16,7 @@ use Composer\Composer;
|
|||
use Composer\EventDispatcher\EventSubscriberInterface;
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Package\Package;
|
||||
use Composer\Semver\VersionParser;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
use Composer\Repository\RepositoryInterface;
|
||||
use Composer\Package\AliasPackage;
|
||||
use Composer\Package\PackageInterface;
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Composer\Repository;
|
|||
use Composer\Package\AliasPackage;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Package\CompletePackageInterface;
|
||||
use Composer\Semver\VersionParser;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
use Composer\Semver\Constraint\ConstraintInterface;
|
||||
use Composer\Semver\Constraint\Constraint;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Composer\Repository;
|
|||
use Composer\Package\Loader\ArrayLoader;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Package\AliasPackage;
|
||||
use Composer\Semver\VersionParser;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
use Composer\DependencyResolver\Pool;
|
||||
use Composer\Json\JsonFile;
|
||||
use Composer\Cache;
|
||||
|
|
|
@ -18,7 +18,7 @@ use Composer\Json\JsonFile;
|
|||
use Composer\Package\Loader\ArrayLoader;
|
||||
use Composer\Package\Locker;
|
||||
use Composer\Package\Version\VersionGuesser;
|
||||
use Composer\Semver\VersionParser;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
use Composer\Util\ProcessExecutor;
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
namespace Composer\Repository;
|
||||
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Semver\VersionParser;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
use Composer\Repository\Pear\ChannelReader;
|
||||
use Composer\Package\CompletePackage;
|
||||
use Composer\Repository\Pear\ChannelInfo;
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Composer\Repository;
|
|||
use Composer\Config;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Package\CompletePackage;
|
||||
use Composer\Semver\VersionParser;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
use Composer\Plugin\PluginInterface;
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Composer\Repository;
|
|||
|
||||
use Composer\Downloader\TransportException;
|
||||
use Composer\Repository\Vcs\VcsDriverInterface;
|
||||
use Composer\Semver\VersionParser;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
use Composer\Package\Loader\ArrayLoader;
|
||||
use Composer\Package\Loader\ValidatingArrayLoader;
|
||||
use Composer\Package\Loader\InvalidPackageException;
|
||||
|
|
Loading…
Reference in New Issue