Improve build efficiency by preventing duplicate merges
Introduced a private property to the `NccCompiler` class, `$merged_dependencies`, to keep track of the dependencies that have already been merged. This prevents unnecessary re-merging during the build operation, potentially enhancing the efficiency of the process. The implementation involves a check for a preexisting merge before a new merge is performed. If a merge already exists, the process is skipped, thereby avoiding redundancies.
This commit is contained in:
parent
12d7744e1e
commit
89d3af8680
2 changed files with 12 additions and 1 deletions
|
@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
This update introduces minor bug fixes.
|
This update introduces minor bug fixes.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Improve build efficiency by preventing duplicate merges
|
||||||
|
|
||||||
|
|
||||||
## [2.0.3] - 2023-10-17
|
## [2.0.3] - 2023-10-17
|
||||||
|
|
||||||
|
|
|
@ -59,11 +59,17 @@
|
||||||
*/
|
*/
|
||||||
private $project_manager;
|
private $project_manager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $merged_dependencies;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ProjectManager $project_manager
|
* @param ProjectManager $project_manager
|
||||||
*/
|
*/
|
||||||
public function __construct(ProjectManager $project_manager)
|
public function __construct(ProjectManager $project_manager)
|
||||||
{
|
{
|
||||||
|
$this->merged_dependencies = [];
|
||||||
$this->project_manager = $project_manager;
|
$this->project_manager = $project_manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,6 +95,7 @@
|
||||||
*/
|
*/
|
||||||
public function build(string $build_configuration=BuildConfigurationValues::DEFAULT, array $options=[]): string
|
public function build(string $build_configuration=BuildConfigurationValues::DEFAULT, array $options=[]): string
|
||||||
{
|
{
|
||||||
|
$this->merged_dependencies = [];
|
||||||
$configuration = $this->project_manager->getProjectConfiguration()->getBuild()->getBuildConfiguration($build_configuration);
|
$configuration = $this->project_manager->getProjectConfiguration()->getBuild()->getBuildConfiguration($build_configuration);
|
||||||
$configuration->setOptions(array_merge($configuration->getOptions(), $options));
|
$configuration->setOptions(array_merge($configuration->getOptions(), $options));
|
||||||
$static_dependencies = isset($configuration->getOptions()[BuildConfigurationOptions::STATIC_DEPENDENCIES]);
|
$static_dependencies = isset($configuration->getOptions()[BuildConfigurationOptions::STATIC_DEPENDENCIES]);
|
||||||
|
@ -234,13 +241,14 @@
|
||||||
/** @noinspection UnusedFunctionResultInspection */
|
/** @noinspection UnusedFunctionResultInspection */
|
||||||
$package_writer->addDependencyConfiguration($dependency);
|
$package_writer->addDependencyConfiguration($dependency);
|
||||||
|
|
||||||
if(!$static)
|
if(!$static || in_array($dependency->getName(), $this->merged_dependencies, true))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$entry = (new PackageManager())->getPackageLock()->getVersionEntry($dependency->getName(), $dependency->getVersion());
|
$entry = (new PackageManager())->getPackageLock()->getVersionEntry($dependency->getName(), $dependency->getVersion());
|
||||||
$package_writer->merge((new PackageReader($entry->getShadowPackagePath($dependency->getName()))));
|
$package_writer->merge((new PackageReader($entry->getShadowPackagePath($dependency->getName()))));
|
||||||
|
$this->merged_dependencies[] = $dependency->getName();
|
||||||
|
|
||||||
foreach($entry->getDependencies() as $sub_dependency)
|
foreach($entry->getDependencies() as $sub_dependency)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue