Commit f5bd37e7 authored by RichardWaiteSTFC's avatar RichardWaiteSTFC
Browse files

Pre-allocate memory and pass arguments by reference in CoordTransform

parent 4d21e679
......@@ -41,8 +41,8 @@ public:
CoordTransformDistance(
const size_t inD, const coord_t *center, const bool *dimensionsUsed,
const size_t outD = 1,
const std::vector<Kernel::V3D> directions = std::vector<Kernel::V3D>(0),
const std::vector<double> abcRadii = std::vector<double>(0, 0.0));
const std::vector<Kernel::V3D> &eigenvects = std::vector<Kernel::V3D>(0),
const std::vector<double> &eigenvals = std::vector<double>(0, 0.0));
CoordTransform *clone() const override;
std::string toXMLString() const override;
......@@ -51,10 +51,10 @@ public:
void apply(const coord_t *inputVector, coord_t *outVector) const override;
/// Return the center coordinate array
const std::vector<coord_t> getCenter() { return m_center; }
const std::vector<coord_t> &getCenter() { return m_center; }
/// Return the dimensions used bool array
const std::vector<bool> getDimensionsUsed() { return m_dimensionsUsed; }
const std::vector<bool> &getDimensionsUsed() { return m_dimensionsUsed; }
protected:
/// Coordinates at the center
......
......@@ -34,10 +34,13 @@ namespace DataObjects {
*/
CoordTransformDistance::CoordTransformDistance(
const size_t inD, const coord_t *center, const bool *dimensionsUsed,
const size_t outD, const std::vector<Kernel::V3D> eigenvects,
const std::vector<double> eigenvals)
const size_t outD, const std::vector<Kernel::V3D> &eigenvects,
const std::vector<double> &eigenvals)
: CoordTransform(inD, outD) {
m_center.reserve(inD);
m_dimensionsUsed.reserve(inD);
m_eigenvals.reserve(inD);
m_maxEigenval = 0.0;
for (size_t d = 0; d < inD; d++) {
m_center.push_back(center[d]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment