diff options
author | David Blaikie <dblaikie@gmail.com> | 2017-01-04 21:13:28 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2017-01-04 21:13:28 +0000 |
commit | 2ff18584a9d3ce07b9fdf4aa24540a5b4b9d5f34 (patch) | |
tree | d4ec908be96c7d9d8d57fbc4d854f208bbffcf16 | |
parent | 020af9c25869039e8da86acfb42814f0b1f40d5f (diff) | |
download | bcm5719-llvm-2ff18584a9d3ce07b9fdf4aa24540a5b4b9d5f34.tar.gz bcm5719-llvm-2ff18584a9d3ce07b9fdf4aa24540a5b4b9d5f34.zip |
Remove unnecessary intrusive ref counting in favor of std::shared_ptr/make_shared
The intrusive nature of the reference counting is not required/used
here, so simplify the ownership model to make the code easier to
understand.
llvm-svn: 291005
-rw-r--r-- | llvm/include/llvm/Support/FileSystem.h | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/llvm/include/llvm/Support/FileSystem.h b/llvm/include/llvm/Support/FileSystem.h index 9d8d8c3ffb5..347f2110891 100644 --- a/llvm/include/llvm/Support/FileSystem.h +++ b/llvm/include/llvm/Support/FileSystem.h @@ -769,17 +769,13 @@ namespace detail { std::error_code directory_iterator_increment(DirIterState &); std::error_code directory_iterator_destruct(DirIterState &); - /// DirIterState - Keeps state for the directory_iterator. It is reference - /// counted in order to preserve InputIterator semantics on copy. - struct DirIterState : public RefCountedBase<DirIterState> { - DirIterState() - : IterationHandle(0) {} - + /// Keeps state for the directory_iterator. + struct DirIterState { ~DirIterState() { directory_iterator_destruct(*this); } - intptr_t IterationHandle; + intptr_t IterationHandle = 0; directory_entry CurrentEntry; }; } // end namespace detail @@ -788,23 +784,23 @@ namespace detail { /// operator++ because we need an error_code. If it's really needed we can make /// it call report_fatal_error on error. class directory_iterator { - IntrusiveRefCntPtr<detail::DirIterState> State; + std::shared_ptr<detail::DirIterState> State; public: explicit directory_iterator(const Twine &path, std::error_code &ec) { - State = new detail::DirIterState; + State = std::make_shared<detail::DirIterState>(); SmallString<128> path_storage; ec = detail::directory_iterator_construct(*State, path.toStringRef(path_storage)); } explicit directory_iterator(const directory_entry &de, std::error_code &ec) { - State = new detail::DirIterState; + State = std::make_shared<detail::DirIterState>(); ec = detail::directory_iterator_construct(*State, de.path()); } /// Construct end iterator. - directory_iterator() : State(nullptr) {} + directory_iterator() = default; // No operator++ because we need error_code. directory_iterator &increment(std::error_code &ec) { |