mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-29 18:51:15 -03:00
Share logic between move constructor/assignment of dir_iter_t
The parent commit made the destructor of the DIR* member close it if necessary (i.e. only if it's not null). This means that we can use the same logic in the move constructor (where the source DIR* is null) and for move assignment (where it might not be). No functional change.
This commit is contained in:
@@ -181,16 +181,10 @@ dir_iter_t::dir_iter_t(const wcstring &path) {
|
||||
entry_.dirfd_ = dirfd(&*dir_);
|
||||
}
|
||||
|
||||
dir_iter_t::dir_iter_t(dir_iter_t &&rhs) {
|
||||
// Steal the fields; ensure rhs no longer has FILE* and forgets its fd.
|
||||
this->dir_ = std::move(rhs.dir_);
|
||||
this->error_ = rhs.error_;
|
||||
this->entry_ = std::move(rhs.entry_);
|
||||
rhs.dir_ = nullptr;
|
||||
rhs.entry_.dirfd_ = -1;
|
||||
}
|
||||
dir_iter_t::dir_iter_t(dir_iter_t &&rhs) { *this = std::move(rhs); }
|
||||
|
||||
dir_iter_t &dir_iter_t::operator=(dir_iter_t &&rhs) {
|
||||
// Steal the fields; ensure rhs no longer has DIR* and forgets its fd.
|
||||
this->dir_ = std::move(rhs.dir_);
|
||||
this->error_ = rhs.error_;
|
||||
this->entry_ = std::move(rhs.entry_);
|
||||
|
||||
Reference in New Issue
Block a user