Skip to content

Commit

Permalink
const ref args
Browse files Browse the repository at this point in the history
  • Loading branch information
rraustad committed Dec 26, 2024
1 parent cf6b3af commit e2e3930
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/EnergyPlus/GroundHeatExchangers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ void GLHEVert::calcShortTimestepGFunctions(EnergyPlusData &state)

//******************************************************************************

std::vector<Real64> TDMA(std::vector<Real64> a, std::vector<Real64> b, std::vector<Real64> c, std::vector<Real64> d)
std::vector<Real64> TDMA(std::vector<Real64> const &a, std::vector<Real64> const &b, std::vector<Real64> c, std::vector<Real64> d)

This comment has been minimized.

Copy link
@amirroth

amirroth Dec 26, 2024

Collaborator

The bigger question is why c and d are passed by value. You should never pass an array/vector/struct/object by value. Always by reference/pointer or const reference/pointer. See this wiki page.

{
// from: https://en.wikibooks.org/wiki/Algorithm_Implementation/Linear_Algebra/Tridiagonal_matrix_algorithm#C.2B.2B

Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/GroundHeatExchangers.hh
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ namespace GroundHeatExchangers {

std::shared_ptr<GLHEVertArray> GetVertArray(EnergyPlusData &state, std::string const &objectName);

std::vector<Real64> TDMA(std::vector<Real64> a, std::vector<Real64> b, std::vector<Real64> c, std::vector<Real64> d);
std::vector<Real64> TDMA(std::vector<Real64> const &a, std::vector<Real64> const &b, std::vector<Real64> c, std::vector<Real64> d);

} // namespace GroundHeatExchangers

Expand Down
4 changes: 2 additions & 2 deletions src/EnergyPlus/SurfaceGeometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12081,7 +12081,7 @@ namespace SurfaceGeometry {
}

// returns a vector of edges that are in both vectors
std::vector<EdgeOfSurf> edgesInBoth(std::vector<EdgeOfSurf> edges1, std::vector<EdgeOfSurf> edges2)
std::vector<EdgeOfSurf> edgesInBoth(std::vector<EdgeOfSurf> const &edges1, std::vector<EdgeOfSurf> const &edges2)
{
// J. Glazer - June 2017
// this is not optimized but the number of edges for a typical polyhedron is 12 and is probably rarely bigger than 20.
Expand Down Expand Up @@ -12505,7 +12505,7 @@ namespace SurfaceGeometry {
}

// returns the index of vertex in a list that is in the same position in space as the given vertex
int findIndexOfVertex(DataVectorTypes::Vector vertexToFind, std::vector<DataVectorTypes::Vector> listOfVertices)
int findIndexOfVertex(DataVectorTypes::Vector vertexToFind, std::vector<DataVectorTypes::Vector> const &listOfVertices)
{
// J. Glazer - March 2017

Expand Down
4 changes: 2 additions & 2 deletions src/EnergyPlus/SurfaceGeometry.hh
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ namespace SurfaceGeometry {

bool isEnclosedVolume(DataVectorTypes::Polyhedron const &zonePoly, std::vector<EdgeOfSurf> &edgeNot2);

std::vector<EdgeOfSurf> edgesInBoth(std::vector<EdgeOfSurf> edges1, std::vector<EdgeOfSurf> edges2);
std::vector<EdgeOfSurf> edgesInBoth(std::vector<EdgeOfSurf> const &edges1, std::vector<EdgeOfSurf> const &edges2);

bool edgesEqualOnSameSurface(EdgeOfSurf a, EdgeOfSurf b);

Expand Down Expand Up @@ -365,7 +365,7 @@ namespace SurfaceGeometry {

bool isAlmostEqual2dPt(DataVectorTypes::Vector_2d v1, DataVectorTypes::Vector_2d v2);

int findIndexOfVertex(DataVectorTypes::Vector vertexToFind, std::vector<DataVectorTypes::Vector> listOfVertices);
int findIndexOfVertex(DataVectorTypes::Vector vertexToFind, std::vector<DataVectorTypes::Vector> const &listOfVertices);

Real64 distance(DataVectorTypes::Vector v1, DataVectorTypes::Vector v2);

Expand Down

3 comments on commit e2e3930

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CppCheck-consts (rraustad) - x86_64-Linux-Ubuntu-24.04-gcc-13.3-UnitTestsCoverage-RelWithDebInfo: Tests Failed (17 of 2100 tests passed, 0 test warnings)

Failures:\n

API Test Summary

  • Passed: 10
  • Failed: 1
  • notrun: 5

Build Badge Test Badge Coverage Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CppCheck-consts (rraustad) - x86_64-Linux-Ubuntu-24.04-gcc-13.3: OK (2918 of 2918 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CppCheck-consts (rraustad) - x86_64-Linux-Ubuntu-24.04-gcc-13.3-IntegrationCoverage-RelWithDebInfo: Tests Failed (2 of 801 tests passed, 0 test warnings)

Failures:\n

integration Test Summary

  • Passed: 2
  • Failed: 799

Build Badge Test Badge Coverage Badge

Please sign in to comment.