diff options
author | Nathan Sidwell <nathan@acm.org> | 2022-02-28 23:04:37 +0300 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2022-03-01 15:37:24 +0300 |
commit | e5c98e22fbbe3c3eb5f2c782d0789098afc81518 (patch) | |
tree | becf0b04f9803eed105479f168dfc17feb6b5aff /libcxxabi/src/demangle | |
parent | 3cdc1c155b40897a17d7fd61092d2f6fd21fb7ef (diff) |
[demangler] Simplify SwapAndRestore
The SwapAndRestore class is over engineered. Nothing makes use of the
early restoration machinery. Let's just remove that cognative burdon.
Reviewed By: ChuanqiXu
Differential Revision: https://reviews.llvm.org/D120673
Diffstat (limited to 'libcxxabi/src/demangle')
-rw-r--r-- | libcxxabi/src/demangle/Utility.h | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/libcxxabi/src/demangle/Utility.h b/libcxxabi/src/demangle/Utility.h index 21e5efb18542..f8190b81332a 100644 --- a/libcxxabi/src/demangle/Utility.h +++ b/libcxxabi/src/demangle/Utility.h @@ -163,7 +163,6 @@ public: template <class T> class SwapAndRestore { T &Restore; T OriginalValue; - bool ShouldRestore = true; public: SwapAndRestore(T &Restore_) : SwapAndRestore(Restore_, Restore_) {} @@ -172,20 +171,7 @@ public: : Restore(Restore_), OriginalValue(Restore) { Restore = std::move(NewVal); } - ~SwapAndRestore() { - if (ShouldRestore) - Restore = std::move(OriginalValue); - } - - void shouldRestore(bool ShouldRestore_) { ShouldRestore = ShouldRestore_; } - - void restoreNow(bool Force) { - if (!Force && !ShouldRestore) - return; - - Restore = std::move(OriginalValue); - ShouldRestore = false; - } + ~SwapAndRestore() { Restore = std::move(OriginalValue); } SwapAndRestore(const SwapAndRestore &) = delete; SwapAndRestore &operator=(const SwapAndRestore &) = delete; |