X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/93a3786624b2768d89bfa27e46598dc64e2fb70a..refs/heads/master:/heap/WeakInlines.h?ds=sidebyside diff --git a/heap/WeakInlines.h b/heap/WeakInlines.h index 221b6c1..fe61447 100644 --- a/heap/WeakInlines.h +++ b/heap/WeakInlines.h @@ -26,7 +26,7 @@ #ifndef WeakInlines_h #define WeakInlines_h -#include "PassWeak.h" +#include "JSCell.h" #include "WeakSetInlines.h" #include #include @@ -48,7 +48,7 @@ template inline Weak::Weak(typename Weak::HashTableDeletedValu { } -template template inline Weak::Weak(const PassWeak& other) +template inline Weak::Weak(Weak&& other) : m_impl(other.leakImpl()) { } @@ -63,10 +63,10 @@ template inline void Weak::swap(Weak& other) std::swap(m_impl, other.m_impl); } -template inline Weak& Weak::operator=(const PassWeak& o) +template inline auto Weak::operator=(Weak&& other) -> Weak& { - clear(); - m_impl = o.leakImpl(); + Weak weak = WTF::move(other); + swap(weak); return *this; } @@ -91,7 +91,7 @@ template inline T* Weak::get() const template inline bool Weak::was(T* other) const { - return jsCast(m_impl->jsValue().asCell()) == other; + return static_cast(m_impl->jsValue().asCell()) == other; } template inline bool Weak::operator!() const @@ -104,11 +104,11 @@ template inline Weak::operator UnspecifiedBoolType*() const return reinterpret_cast(!!*this); } -template inline PassWeak Weak::release() +template inline WeakImpl* Weak::leakImpl() { - PassWeak tmp = adoptWeak(m_impl); - m_impl = 0; - return tmp; + WeakImpl* impl = m_impl; + m_impl = nullptr; + return impl; } template inline WeakImpl* Weak::hashTableDeletedValue() @@ -123,10 +123,10 @@ template inline bool operator==(const Weak& lhs, const Weak& // This function helps avoid modifying a weak table while holding an iterator into it. (Object allocation // can run a finalizer that modifies the table. We avoid that by requiring a pre-constructed object as our value.) -template inline void weakAdd(Map& map, const Key& key, Value value) +template inline void weakAdd(Map& map, const Key& key, Value&& value) { ASSERT(!map.get(key)); - map.set(key, value); // The table may still have a zombie for value. + map.set(key, std::forward(value)); // The table may still have a zombie for value. } template inline void weakRemove(Map& map, const Key& key, Value value) @@ -151,23 +151,16 @@ template inline void weakClear(Weak& weak, T* cell) namespace WTF { -template struct VectorTraits > : SimpleClassVectorTraits { +template struct VectorTraits> : SimpleClassVectorTraits { static const bool canCompareWithMemcmp = false; }; -template struct HashTraits > : SimpleClassHashTraits > { +template struct HashTraits> : SimpleClassHashTraits> { typedef JSC::Weak StorageType; typedef std::nullptr_t EmptyValueType; static EmptyValueType emptyValue() { return nullptr; } - typedef JSC::PassWeak PassInType; - static void store(PassInType value, StorageType& storage) { storage = value; } - - typedef JSC::PassWeak PassOutType; - static PassOutType passOut(StorageType& value) { return value.release(); } - static PassOutType passOut(EmptyValueType) { return PassOutType(); } - typedef T* PeekType; static PeekType peek(const StorageType& value) { return value.get(); } static PeekType peek(EmptyValueType) { return PeekType(); }