From 73553d3b3d471b7a0b1dd4aec06b3b09b8e7bb9e Mon Sep 17 00:00:00 2001 From: Carlo Varni <75478407+CarloVarni@users.noreply.github.com> Date: Thu, 21 Dec 2023 11:16:02 +0100 Subject: [PATCH] fix: Move objects instead of copying (#2848) Totally unnecessary copy of locally-defined objects (vector and axes). Can be simply moved instead. Other changes: - `config.zBinEdges` contains `float`s. No need to get reference when looping - `std::max` returns same type of the two input arguments and `std::floor` returns a `float`. Thus `zBins` can already be defined as a `float` instead of `int`, thus avoiding a few `static_cast`s --- Core/include/Acts/Seeding/SpacePointGrid.ipp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Core/include/Acts/Seeding/SpacePointGrid.ipp b/Core/include/Acts/Seeding/SpacePointGrid.ipp index d1e4ccf86f1..5577df32acf 100644 --- a/Core/include/Acts/Seeding/SpacePointGrid.ipp +++ b/Core/include/Acts/Seeding/SpacePointGrid.ipp @@ -115,24 +115,24 @@ Acts::SpacePointGridCreator::createGrid( // seeds // FIXME: zBinSize must include scattering float zBinSize = config.cotThetaMax * config.deltaRMax; - int zBins = - std::max(1, (int)std::floor((config.zMax - config.zMin) / zBinSize)); + float zBins = + std::max(1.f, std::floor((config.zMax - config.zMin) / zBinSize)); - for (int bin = 0; bin <= zBins; bin++) { + for (int bin = 0; bin <= static_cast(zBins); bin++) { AxisScalar edge = - config.zMin + bin * ((config.zMax - config.zMin) / (float)zBins); + config.zMin + bin * ((config.zMax - config.zMin) / zBins); zValues.push_back(edge); } } else { // Use the zBinEdges defined in the config - for (auto& bin : config.zBinEdges) { + for (float bin : config.zBinEdges) { zValues.push_back(bin); } } detail::Axis - zAxis(zValues); + zAxis(std::move(zValues)); return std::make_unique>( - std::make_tuple(phiAxis, zAxis)); + std::make_tuple(std::move(phiAxis), std::move(zAxis))); }