Skip to content

Commit

Permalink
const_cast to avoid unnecessary copy of vector<string>
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir committed Aug 25, 2023
1 parent 811fda7 commit 6104052
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/solver/utils/named_problem.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ struct PROBLEME_SIMPLEXE_NOMME : public PROBLEME_SIMPLEXE
bool UseNamedProblems);

private:
std::vector<std::string> NomDesVariables;
std::vector<std::string> NomDesContraintes;
const std::vector<std::string>& NomDesVariables;
const std::vector<std::string>& NomDesContraintes;
bool useNamedProblems_;

public:
Expand All @@ -63,7 +63,8 @@ struct PROBLEME_SIMPLEXE_NOMME : public PROBLEME_SIMPLEXE
{
if (useNamedProblems_)
{
return VectorOfStringToCharPP(NomDesVariables, pointerVec);
return VectorOfStringToCharPP(const_cast<std::vector<std::string>&>(NomDesVariables),
pointerVec);
}

return CharPP(NomDesVariables.size(), pointerVec);
Expand All @@ -73,7 +74,8 @@ struct PROBLEME_SIMPLEXE_NOMME : public PROBLEME_SIMPLEXE
{
if (useNamedProblems_)
{
return VectorOfStringToCharPP(NomDesContraintes, pointerVec);
return VectorOfStringToCharPP(const_cast<std::vector<std::string>&>(NomDesContraintes),
pointerVec);
}
return CharPP(NomDesContraintes.size(), pointerVec);
}
Expand Down

0 comments on commit 6104052

Please sign in to comment.