Skip to content

Commit

Permalink
feat: use 'using' instead of Dispose, for brevity
Browse files Browse the repository at this point in the history
  • Loading branch information
shpaass committed May 10, 2024
1 parent 394bb6f commit c3f7b33
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions Yafc.Model/Model/ProductionTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ private static void AddLinkCoef(Constraint cst, Variable var, ProductionLink lin
}

public override async Task<string> Solve(ProjectPage page) {
var productionTableSolver = DataUtils.CreateSolver();
using var productionTableSolver = DataUtils.CreateSolver();
var objective = productionTableSolver.Objective();
objective.SetMinimization();
List<RecipeRow> allRecipes = [];
Expand Down Expand Up @@ -410,7 +410,6 @@ public override async Task<string> Solve(ProjectPage page) {
}
}
else {
productionTableSolver.Dispose();
if (result == Solver.ResultStatus.INFEASIBLE) {
return "YAFC failed to solve the model and to find deadlock loops. As a result, the model was not updated.";
}
Expand Down Expand Up @@ -446,7 +445,6 @@ public override async Task<string> Solve(ProjectPage page) {
bool builtCountExceeded = CheckBuiltCountExceeded();

CalculateFlow(null);
productionTableSolver.Dispose();
return builtCountExceeded ? "This model requires more buildings than are currently built" : null;
}

Expand Down

0 comments on commit c3f7b33

Please sign in to comment.