From 66bcf2095063e479f06c35c1a7e67f8073414bda Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 10 Aug 2020 09:33:46 -0600 Subject: [PATCH] ensure that all Region methods accepting timepos_t use a const & to avoid copy-construction --- libs/ardour/ardour/region.h | 30 +++++++++++++++--------------- libs/ardour/region.cc | 30 +++++++++++++++--------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h index 4b2662fb81..77fc8c8871 100644 --- a/libs/ardour/ardour/region.h +++ b/libs/ardour/ardour/region.h @@ -159,7 +159,7 @@ public: timecnt_t sync_offset (int& dir) const; timepos_t sync_position () const; - timepos_t adjust_to_sync (timepos_t) const; + timepos_t adjust_to_sync (timepos_t const &) const; /* first_sample() is an alias; last_sample() just hides some math */ @@ -244,9 +244,9 @@ public: void set_length (timecnt_t const &); void set_start (timecnt_t const &); - void set_position (timepos_t); - void set_initial_position (timepos_t); - void special_set_position (timepos_t); + void set_position (timepos_t const &); + void set_initial_position (timepos_t const &); + void special_set_position (timepos_t const &); virtual void update_after_tempo_map_change (bool send_change = true); void nudge_position (timecnt_t const &); @@ -254,15 +254,15 @@ public: void move_to_natural_position (); void move_start (timecnt_t const & distance); - void trim_front (timepos_t new_position); - void trim_end (timepos_t new_position); - void trim_to (timepos_t pos, timecnt_t const & length); + void trim_front (timepos_t const & new_position); + void trim_end (timepos_t const & new_position); + void trim_to (timepos_t const & pos, timecnt_t const & length); /* fades are inherently audio in nature and we specify them in samples */ virtual void fade_range (samplepos_t, samplepos_t) {} - void cut_front (timepos_t new_position); - void cut_end (timepos_t new_position); + void cut_front (timepos_t const & new_position); + void cut_end (timepos_t const & new_position); void set_layer (layer_t l); /* ONLY Playlist can call this */ void raise (); @@ -270,7 +270,7 @@ public: void raise_to_top (); void lower_to_bottom (); - void set_sync_position (timepos_t n); + void set_sync_position (timepos_t const & n); void clear_sync_position (); void set_hidden (bool yn); void set_muted (bool yn); @@ -413,7 +413,7 @@ protected: Region (boost::shared_ptr, const SourceList&); /** Constructor for derived types only */ - Region (Session& s, timepos_t start, timecnt_t length, const std::string& name, DataType); + Region (Session& s, timepos_t const & start, timecnt_t length, const std::string& name, DataType); virtual bool can_trim_start_before_source_start () const { return false; @@ -424,7 +424,7 @@ protected: void send_change (const PBD::PropertyChange&); virtual int _set_state (const XMLNode&, int version, PBD::PropertyChange& what_changed, bool send_signal); void post_set (const PBD::PropertyChange&); - virtual void set_position_internal (timepos_t pos); + virtual void set_position_internal (timepos_t const & pos); virtual void set_length_internal (timecnt_t const &); virtual void set_start_internal (timecnt_t const &); bool verify_start_and_length (timecnt_t const &, timecnt_t&); @@ -469,9 +469,9 @@ protected: private: void mid_thaw (const PBD::PropertyChange&); - virtual void trim_to_internal (timepos_t position, timecnt_t const & length); - void modify_front (timepos_t new_position, bool reset_fade); - void modify_end (timepos_t new_position, bool reset_fade); + virtual void trim_to_internal (timepos_t const & position, timecnt_t const & length); + void modify_front (timepos_t const & new_position, bool reset_fade); + void modify_end (timepos_t const & new_position, bool reset_fade); void maybe_uncopy (); diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index 62614fb653..9ddd8594fa 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -254,7 +254,7 @@ Region::register_properties () , _contents (Properties::contents, other->_contents) /* derived-from-derived constructor (no sources in constructor) */ -Region::Region (Session& s, timepos_t start, timecnt_t length, const string& name, DataType type) +Region::Region (Session& s, timepos_t const & start, timecnt_t length, const string& name, DataType type) : SessionObject(s, name) , _type(type) , REGION_DEFAULT_STATE(start,length) @@ -576,7 +576,7 @@ Region::move_to_natural_position () } void -Region::special_set_position (timepos_t pos) +Region::special_set_position (timepos_t const & pos) { /* this is used when creating a whole file region as * a way to store its "natural" or "captured" position. @@ -621,7 +621,7 @@ Region::update_after_tempo_map_change (bool send) } void -Region::set_position (timepos_t pos) +Region::set_position (timepos_t const & pos) { if (!can_move()) { return; @@ -652,7 +652,7 @@ Region::set_position (timepos_t pos) } void -Region::set_position_internal (timepos_t pos) +Region::set_position_internal (timepos_t const & pos) { /* We emit a change of Properties::position even if the position hasn't changed * (see Region::set_position), so we must always set this up so that @@ -684,7 +684,7 @@ Region::set_position_internal (timepos_t pos) * _last_position to prevent an implied move. */ void -Region::set_initial_position (timepos_t pos) +Region::set_initial_position (timepos_t const & pos) { if (!can_move()) { return; @@ -838,25 +838,25 @@ Region::move_start (timecnt_t const & distance) } void -Region::trim_front (timepos_t new_position) +Region::trim_front (timepos_t const & new_position) { modify_front (new_position, false); } void -Region::cut_front (timepos_t new_position) +Region::cut_front (timepos_t const & new_position) { modify_front (new_position, true); } void -Region::cut_end (timepos_t new_endpoint) +Region::cut_end (timepos_t const & new_endpoint) { modify_end (new_endpoint, true); } void -Region::modify_front (timepos_t new_position, bool reset_fade) +Region::modify_front (timepos_t const & new_position, bool reset_fade) { if (locked()) { return; @@ -902,7 +902,7 @@ Region::modify_front (timepos_t new_position, bool reset_fade) } void -Region::modify_end (timepos_t new_endpoint, bool reset_fade) +Region::modify_end (timepos_t const & new_endpoint, bool reset_fade) { if (locked()) { return; @@ -923,13 +923,13 @@ Region::modify_end (timepos_t new_endpoint, bool reset_fade) * a region at 0 of length 10 has an endpoint of 9. */ void -Region::trim_end (timepos_t new_endpoint) +Region::trim_end (timepos_t const & new_endpoint) { modify_end (new_endpoint, false); } void -Region::trim_to (timepos_t position, timecnt_t const & length) +Region::trim_to (timepos_t const & position, timecnt_t const & length) { if (locked()) { return; @@ -944,7 +944,7 @@ Region::trim_to (timepos_t position, timecnt_t const & length) } void -Region::trim_to_internal (timepos_t position, timecnt_t const & length) +Region::trim_to_internal (timepos_t const & position, timecnt_t const & length) { timecnt_t new_start; @@ -1100,7 +1100,7 @@ Region::set_position_locked (bool yn) * @param absolute_pos Session time. */ void -Region::set_sync_position (timepos_t absolute_pos) +Region::set_sync_position (timepos_t const & absolute_pos) { /* position within our file */ const timecnt_t file_pos = nt_start() + nt_position().distance (absolute_pos); @@ -1148,7 +1148,7 @@ Region::sync_offset (int& dir) const } timepos_t -Region::adjust_to_sync (timepos_t pos) const +Region::adjust_to_sync (timepos_t const & pos) const { int sync_dir; timepos_t p = pos;