Skip to content

pass by reference / const correctness #3

Description

@lkeegan

Probably both of these parameters should be passed by const-reference instead of by value?:

get_potential(const std::complex<double> site, const std::vector<std::complex<double> *> neighbours) {

(passing a vector by const value is quite expensive compared to passing a const reference, even for a small vector like this one, because passing by value makes a copy, which requires it to allocate memory on the heap)

Also it looks like these methods could also all be marked const, as they don't alter any of the class member variables? e.g.

get_potential(const std::complex<double>& site, const std::vector<std::complex<double> *>& neighbours) const

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions