diff --git a/src/history.cpp b/src/history.cpp index 868c97557..5c6e24bc5 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -238,7 +238,7 @@ struct history_impl_t { // item_at_index until a call to resolve_pending(). Pending items are tracked with an offset // into the array of new items, so adding a non-pending item has the effect of resolving all // pending items. - void add(history_item_t item, bool pending = false, bool do_save = true); + void add(history_item_t &&item, bool pending = false, bool do_save = true); // Internal function. void clear_file_state(); @@ -379,7 +379,7 @@ struct history_impl_t { size_t size(); }; -void history_impl_t::add(history_item_t item, bool pending, bool do_save) { +void history_impl_t::add(history_item_t &&item, bool pending, bool do_save) { assert(item.timestamp() != 0 && "Should not add an item with a 0 timestamp"); // We use empty items as sentinels to indicate the end of history. // Do not allow them to be added (#6032). @@ -1096,7 +1096,7 @@ bool history_impl_t::is_empty() { void history_t::add(wcstring str) { auto imp = this->impl(); - time_t when = imp->timestamp_now(); + time_t when = imp->timestamp_now(); imp->add(history_item_t(std::move(str), when)); } @@ -1327,7 +1327,7 @@ bool history_t::is_default() const { return impl()->is_default(); } bool history_t::is_empty() { return impl()->is_empty(); } -void history_t::add(history_item_t item, bool pending) { impl()->add(std::move(item), pending); } +void history_t::add(history_item_t &&item, bool pending) { impl()->add(std::move(item), pending); } void history_t::remove(const wcstring &str) { impl()->remove(str); } diff --git a/src/history.h b/src/history.h index daa22f037..8b8dc4bb8 100644 --- a/src/history.h +++ b/src/history.h @@ -146,7 +146,7 @@ class history_t { // Privately add an item. If pending, the item will not be returned by history searches until a // call to resolve_pending. Any trailing ephemeral items are dropped. - void add(history_item_t item, bool pending = false); + void add(history_item_t &&item, bool pending = false); // Add a new history item with text \p str to the end of history. void add(wcstring str); diff --git a/src/timer.cpp b/src/timer.cpp index 0291311f2..699844a61 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -71,7 +71,7 @@ timer_snapshot_t timer_snapshot_t::take() { return snapshot; } -wcstring timer_snapshot_t::print_delta(timer_snapshot_t t1, timer_snapshot_t t2, +wcstring timer_snapshot_t::print_delta(const timer_snapshot_t &t1, const timer_snapshot_t &t2, bool verbose /* = true */) { int64_t fish_sys_micros = micros(t2.cpu_fish.ru_stime) - micros(t1.cpu_fish.ru_stime); int64_t fish_usr_micros = micros(t2.cpu_fish.ru_utime) - micros(t1.cpu_fish.ru_utime); diff --git a/src/timer.h b/src/timer.h index 997e98c11..e43ead5d4 100644 --- a/src/timer.h +++ b/src/timer.h @@ -22,7 +22,8 @@ struct timer_snapshot_t { std::chrono::time_point wall; static timer_snapshot_t take(); - static wcstring print_delta(timer_snapshot_t t1, timer_snapshot_t t2, bool verbose = false); + static wcstring print_delta(const timer_snapshot_t &t1, const timer_snapshot_t &t2, + bool verbose = false); private: timer_snapshot_t() {}