From de353d3e04250d0bb3febd3704265a2aa34469f2 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Thu, 15 Sep 2022 04:13:39 +0200 Subject: [PATCH] reader: stop requiring edit_t to be an rvalue reference While its true that we only ever call this with temporaries, there is no fundamental reason for this restriction. Taking by value is simpler and more flexible. I think it does not change the generated code. No functional change. --- src/reader.cpp | 6 +++--- src/reader.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/reader.cpp b/src/reader.cpp index 2f300be05..5af211a4b 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -254,7 +254,7 @@ void editable_line_t::clear() { set_position(0); } -void editable_line_t::push_edit(edit_t &&edit, bool allow_coalesce) { +void editable_line_t::push_edit(edit_t edit, bool allow_coalesce) { bool is_insertion = edit.length == 0; /// Coalescing insertion does not create a new undo entry but adds to the last insertion. if (allow_coalesce && is_insertion && want_to_coalesce_insertion_of(edit.replacement)) { @@ -830,7 +830,7 @@ class reader_data_t : public std::enable_shared_from_this { void erase_substring(editable_line_t *el, size_t offset, size_t length); /// Replace the text of length @length at @offset by @replacement. void replace_substring(editable_line_t *el, size_t offset, size_t length, wcstring replacement); - void push_edit(editable_line_t *el, edit_t &&edit); + void push_edit(editable_line_t *el, edit_t edit); /// Insert the character into the command line buffer and print it to the screen using syntax /// highlighting, etc. @@ -1714,7 +1714,7 @@ void reader_data_t::insert_string(editable_line_t *el, const wcstring &str) { maybe_refilter_pager(el); } -void reader_data_t::push_edit(editable_line_t *el, edit_t &&edit) { +void reader_data_t::push_edit(editable_line_t *el, edit_t edit) { el->push_edit(std::move(edit), false); maybe_refilter_pager(el); } diff --git a/src/reader.h b/src/reader.h index 79a8154f0..ee4059abb 100644 --- a/src/reader.h +++ b/src/reader.h @@ -96,7 +96,7 @@ class editable_line_t { /// Modify the commandline according to @edit. Most modifications to the /// text should pass through this function. - void push_edit(edit_t &&edit, bool allow_coalesce); + void push_edit(edit_t edit, bool allow_coalesce); /// Undo the most recent edit that was not yet undone. Returns true on success. bool undo();