From 8a19af1f638574a2555b76e4262a164c2e342c18 Mon Sep 17 00:00:00 2001 From: Steffen Schuemann Date: Mon, 22 Feb 2021 23:13:44 +0100 Subject: [PATCH] refs #104, performance related refactoring --- include/ghc/filesystem.hpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index 472c608..82f0415 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -2226,12 +2226,12 @@ GHC_INLINE file_status status_ex(const path& p, std::error_code& ec, file_status if (result == 0) { ec.clear(); file_status fs = detail::file_status_from_st_mode(st.st_mode); + if (sls) { + *sls = fs; + } if (fs.type() == file_type::symlink) { result = ::stat(p.c_str(), &st); if (result == 0) { - if (sls) { - *sls = fs; - } fs = detail::file_status_from_st_mode(st.st_mode); } } @@ -5487,7 +5487,7 @@ public: if (_entry) { _current = _base; _current.append_name(_entry->d_name); - _dir_entry = directory_entry(_current, ec); + _dir_entry.assign(_current, ec); if (ec && (ec.value() == EACCES || ec.value() == EPERM) && (_options & directory_options::skip_permission_denied) == directory_options::skip_permission_denied) { ec.clear(); skip = true; @@ -5730,13 +5730,7 @@ GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::operator+ GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::increment(std::error_code& ec) noexcept { - auto status = (*this)->status(ec); - if (ec) - return *this; - auto symlink_status = (*this)->symlink_status(ec); - if (ec) - return *this; - if (recursion_pending() && is_directory(status) && (!is_symlink(symlink_status) || (options() & directory_options::follow_directory_symlink) != directory_options::none)) { + if (recursion_pending() && (*this)->is_directory() && (!(*this)->is_symlink() || (options() & directory_options::follow_directory_symlink) != directory_options::none)) { _impl->_dir_iter_stack.push(directory_iterator((*this)->path(), _impl->_options, ec)); } else {