Skip to content

Commit 9383fab

Browse files
author
Martin Krulis
committed
Preventing execution boxes to be optimized.
1 parent 112cd5a commit 9383fab

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

app/helpers/ExerciseConfig/Compilation/BoxesOptimizer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ private static function canNodesBeOptimized(Node $first, Node $second): bool {
7979
return false;
8080
}
8181

82+
// check whether both boxes can be optimized
83+
if (!$firstBox->isOptimizable() || !$secondBox->isOptimizable()) {
84+
return false;
85+
}
86+
8287
// check ports counts
8388
if (count($firstBox->getInputPorts()) !== count($secondBox->getInputPorts()) ||
8489
count($firstBox->getOutputPorts()) !== count($secondBox->getOutputPorts())) {

app/helpers/ExerciseConfig/Pipeline/Box/Box.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ public abstract function getType(): string;
7777
*/
7878
public abstract function getCategory(): string;
7979

80+
81+
/**
82+
* Whether the box can be optimized (merged with another box with equal functionality).
83+
* Boxes are optimizable by default, but specific boxes may prevent this behavior if necessary.
84+
* @return bool
85+
*/
86+
public function isOptimizable(): bool
87+
{
88+
return true;
89+
}
90+
8091
/**
8192
* Compile box into set of low-level tasks.
8293
* @param CompilationParams $params

app/helpers/ExerciseConfig/Pipeline/Box/Boxes/base/ExecutionBox.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ public function getCategory(): string {
4545
return BoxCategories::$EXECUTION;
4646
}
4747

48+
public function isOptimizable(): bool
49+
{
50+
return false; // execution boxes are not optimizable, all executions must be performed
51+
}
52+
4853
/**
4954
* Base compilation which creates task, set its type to execution and create
5055
* sandbox configuration. Stdin and stdout are also handled here.

0 commit comments

Comments
 (0)