diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-01-09 18:26:06 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-01-09 18:26:06 +0100 |
commit | d429ac8a6035cd278ed1dc32599118e04ca0d2b6 (patch) | |
tree | d93f3117c142ce0fdcaa0484dafb48de4f01d9cc /js/public/RootingAPI.h | |
parent | 29bf28ca34cb3061d2a6c38f60b01f2d7ca1e1e2 (diff) | |
download | UXP-d429ac8a6035cd278ed1dc32599118e04ca0d2b6.tar UXP-d429ac8a6035cd278ed1dc32599118e04ca0d2b6.tar.gz UXP-d429ac8a6035cd278ed1dc32599118e04ca0d2b6.tar.lz UXP-d429ac8a6035cd278ed1dc32599118e04ca0d2b6.tar.xz UXP-d429ac8a6035cd278ed1dc32599118e04ca0d2b6.zip |
Simplify value setting.
This gets rid of unused boolean return values on setters and a level of
indirection for calls to set values.
Diffstat (limited to 'js/public/RootingAPI.h')
-rw-r--r-- | js/public/RootingAPI.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/js/public/RootingAPI.h b/js/public/RootingAPI.h index 9f6ed8943..ca35ea4a5 100644 --- a/js/public/RootingAPI.h +++ b/js/public/RootingAPI.h @@ -274,6 +274,12 @@ class MOZ_NON_MEMMOVABLE Heap : public js::HeapBase<T> T* unsafeGet() { return &ptr; } + void set(const T& newPtr) { + T tmp = ptr; + ptr = newPtr; + post(tmp, ptr); + } + explicit operator bool() const { return bool(js::BarrierMethods<T>::asGCThingOrNull(ptr)); } @@ -287,12 +293,6 @@ class MOZ_NON_MEMMOVABLE Heap : public js::HeapBase<T> post(GCPolicy<T>::initial(), ptr); } - void set(const T& newPtr) { - T tmp = ptr; - ptr = newPtr; - post(tmp, ptr); - } - void post(const T& prev, const T& next) { js::BarrierMethods<T>::postBarrier(&ptr, prev, next); } @@ -1172,13 +1172,13 @@ class PersistentRooted : public js::PersistentRootedBase<T>, return ptr; } - private: template <typename U> void set(U&& value) { MOZ_ASSERT(initialized()); ptr = mozilla::Forward<U>(value); } + private: // See the comment above Rooted::ptr. using MaybeWrapped = typename mozilla::Conditional< MapTypeToRootKind<T>::kind == JS::RootKind::Traceable, |