diff --git a/src/exec.cpp b/src/exec.cpp index c6115c477..75af77921 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -1106,7 +1106,7 @@ static int exec_subshell_internal(const wcstring &cmd, parser_t &parser, wcstrin io_buffer_t::create(STDOUT_FILENO, io_chain_t(), is_subcmd ? read_byte_limit : 0)); if (io_buffer.get() != NULL) { parser_t &parser = parser_t::principal_parser(); - if (parser.eval(cmd, io_chain_t(io_buffer), SUBST) == 0) { + if (parser.eval(cmd, io_chain_t{io_buffer}, SUBST) == 0) { subcommand_status = proc_get_last_status(); } diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index df66fd4b5..1760944a7 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -920,7 +920,7 @@ static void test_parser() { static void test_1_cancellation(const wchar_t *src) { shared_ptr out_buff(io_buffer_t::create(STDOUT_FILENO, io_chain_t())); - const io_chain_t io_chain(out_buff); + const io_chain_t io_chain{out_buff}; pthread_t thread = pthread_self(); double delay = 0.25 /* seconds */; iothread_perform([=]() { diff --git a/src/io.cpp b/src/io.cpp index 2f8fa32af..5cc0b733c 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -120,15 +120,15 @@ void io_chain_t::remove(const shared_ptr &element) { } } -void io_chain_t::push_back(const shared_ptr &element) { +void io_chain_t::push_back(shared_ptr element) { // Ensure we never push back NULL. - assert(element.get() != NULL); - std::vector >::push_back(element); + assert(element.get() != nullptr); + std::vector >::push_back(std::move(element)); } -void io_chain_t::push_front(const shared_ptr &element) { - assert(element.get() != NULL); - this->insert(this->begin(), element); +void io_chain_t::push_front(shared_ptr element) { + assert(element.get() != nullptr); + this->insert(this->begin(), std::move(element)); } void io_chain_t::append(const io_chain_t &chain) { @@ -253,8 +253,3 @@ shared_ptr io_chain_get(const io_chain_t &src, int fd) { } shared_ptr io_chain_get(io_chain_t &src, int fd) { return src.get_io_for_fd(fd); } - -io_chain_t::io_chain_t(const shared_ptr &data) - : std::vector >(1, data) {} - -io_chain_t::io_chain_t() : std::vector >() {} diff --git a/src/io.h b/src/io.h index cee99ccab..161ec5941 100644 --- a/src/io.h +++ b/src/io.h @@ -270,14 +270,13 @@ class io_buffer_t : public io_pipe_t { size_t buffer_limit = 0); }; -class io_chain_t : public std::vector > { +class io_chain_t : public std::vector> { public: - io_chain_t(); - explicit io_chain_t(const shared_ptr &); + using std::vector>::vector; void remove(const shared_ptr &element); - void push_back(const shared_ptr &element); - void push_front(const shared_ptr &element); + void push_back(shared_ptr element); + void push_front(shared_ptr element); void append(const io_chain_t &chain); shared_ptr get_io_for_fd(int fd) const;