mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 06:05:39 +08:00
Pass some parameters by reference/move
This commit is contained in:
parent
516a70d9cb
commit
508044bce1
|
@ -238,7 +238,7 @@ struct history_impl_t {
|
||||||
// item_at_index until a call to resolve_pending(). Pending items are tracked with an offset
|
// 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
|
// into the array of new items, so adding a non-pending item has the effect of resolving all
|
||||||
// pending items.
|
// 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.
|
// Internal function.
|
||||||
void clear_file_state();
|
void clear_file_state();
|
||||||
|
@ -379,7 +379,7 @@ struct history_impl_t {
|
||||||
size_t size();
|
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");
|
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.
|
// We use empty items as sentinels to indicate the end of history.
|
||||||
// Do not allow them to be added (#6032).
|
// Do not allow them to be added (#6032).
|
||||||
|
@ -1327,7 +1327,7 @@ bool history_t::is_default() const { return impl()->is_default(); }
|
||||||
|
|
||||||
bool history_t::is_empty() { return impl()->is_empty(); }
|
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); }
|
void history_t::remove(const wcstring &str) { impl()->remove(str); }
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,7 @@ class history_t {
|
||||||
|
|
||||||
// Privately add an item. If pending, the item will not be returned by history searches until a
|
// 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.
|
// 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.
|
// Add a new history item with text \p str to the end of history.
|
||||||
void add(wcstring str);
|
void add(wcstring str);
|
||||||
|
|
|
@ -71,7 +71,7 @@ timer_snapshot_t timer_snapshot_t::take() {
|
||||||
return snapshot;
|
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 */) {
|
bool verbose /* = true */) {
|
||||||
int64_t fish_sys_micros = micros(t2.cpu_fish.ru_stime) - micros(t1.cpu_fish.ru_stime);
|
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);
|
int64_t fish_usr_micros = micros(t2.cpu_fish.ru_utime) - micros(t1.cpu_fish.ru_utime);
|
||||||
|
|
|
@ -22,7 +22,8 @@ struct timer_snapshot_t {
|
||||||
std::chrono::time_point<std::chrono::steady_clock> wall;
|
std::chrono::time_point<std::chrono::steady_clock> wall;
|
||||||
|
|
||||||
static timer_snapshot_t take();
|
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:
|
private:
|
||||||
timer_snapshot_t() {}
|
timer_snapshot_t() {}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user