mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-18 21:27:30 +09:00
Simplify value setting.
This gets rid of unused boolean return values on setters and a level of indirection for calls to set values.
This commit is contained in:
parent
0aef7dd2f9
commit
647d6033e0
2 changed files with 39 additions and 66 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue