From 0a9e0a0684d51531f9973b4ffbfc7bd65b03640d Mon Sep 17 00:00:00 2001 From: Jan Grewe Date: Sun, 10 May 2020 16:53:30 +0200 Subject: [PATCH] [dimension/indexOf] passes ticks as an rval ref to avoid copying --- include/nix/Dimensions.hpp | 18 +++++++++--------- src/Dimensions.cpp | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/nix/Dimensions.hpp b/include/nix/Dimensions.hpp index 836be5d49..2e09f024a 100644 --- a/include/nix/Dimensions.hpp +++ b/include/nix/Dimensions.hpp @@ -33,7 +33,7 @@ enum class PositionMatch { * @brief Enumeration providing constants for range matching. * * These constants are used to control the behaviour of the range finding. - * Inclusive means [start, end], i.e. start and end are included + * Inclusive means [start, end], i.e. start and end are included * Exclusive means [start, end), i.e. start is included, end is not */ enum class RangeMatch { @@ -51,7 +51,7 @@ enum class PositionInRange{ InRange, Greater, Less, - + NoRange = -1 }; @@ -709,10 +709,10 @@ class NIXAPI RangeDimension : public base::ImplContainer * Method will return the index of the tick that matches or is close to * position. The way of matching can be controlled using the PositionMatch * enum. - * - * @param position The position. + * + * @param position The position. * @param matching PositionMatch enum entry that defines the matching - * behavior. + * behavior. * * @return boost optional containing the index if valid * @@ -729,17 +729,17 @@ class NIXAPI RangeDimension : public base::ImplContainer * @param start The start position * @param end The end position * @param ticks std::vector of ticks, if empty ({}) they are automatically retrieved - * @param range RangeMatch enum, controls whether end is included or not, + * @param range RangeMatch enum, controls whether end is included or not, * defaults to RangeMatch::Inclusive * * @return Start and end indices returned in a boost::optional * which is invalid if out of range. */ boost::optional> indexOf(double start, double end, - std::vector ticks, + std::vector &&ticks, RangeMatch match = RangeMatch::Inclusive) const; - + /** * @brief Returns the index of the given position * @@ -747,7 +747,7 @@ class NIXAPI RangeDimension : public base::ImplContainer * position. If "less_or_equal" is true, the index of the first tick that is * less or equal is given. If "less_or_equal" is false the index of the * first index that is greater than than position is returned. - * + * * Version 1.4.5: The behavior of this function has been slightly changed, * it now throws an OutOfBounds exception if the position is not in the * range. Use positionInRange(position) to check before calling this function. diff --git a/src/Dimensions.cpp b/src/Dimensions.cpp index 95552c07c..88e25a065 100644 --- a/src/Dimensions.cpp +++ b/src/Dimensions.cpp @@ -458,7 +458,7 @@ boost::optional RangeDimension::indexOf(const double position, Positio boost::optional> RangeDimension::indexOf(double start, double end, - std::vector ticks, + std::vector &&ticks, RangeMatch match) const { if (ticks.size() == 0) { ticks = this->ticks(); @@ -515,7 +515,7 @@ std::vector> RangeDimension::indexOf(const std::ve for (size_t i = 0; i < start_positions.size(); ++i) { boost::optional> range; - range = this->indexOf(start_positions[i], end_positions[i], ticks, match); + range = this->indexOf(start_positions[i], end_positions[i], std::move(ticks), match); if (range) { indices.push_back(*range); }