@@ -34,7 +34,7 @@ THE SOFTWARE.
3434namespace gctools {
3535
3636#ifdef USE_BOEHM
37- WeakPointer::WeakPointer (core::T_sp o) : _value(o.tagged_() ) {
37+ WeakPointer::WeakPointer (core::T_sp o) : _value(o) {
3838 if (o.objectp ()) { // pointer, so we're actually weak
3939 _splattablep = true ;
4040 // note: deregistered automatically if the weak pointer itself is dealloc'd
@@ -45,8 +45,8 @@ WeakPointer::WeakPointer(core::T_sp o) : _value(o.tagged_()) {
4545void * WeakPointer::value_helper (void * data) {
4646 value_helper_s* vhsp = (value_helper_s*)data;
4747 if (vhsp->wp ->_value || !vhsp->wp ->_splattablep ) // not splatted
48- // construct a T_sp in the result
49- vhsp->result . emplace ( vhsp->wp ->_value ) ;
48+ // put a T_sp in the result
49+ vhsp->result = vhsp->wp ->_value ;
5050 // otherwise, leave the result default constructed (no T_sp)
5151 return nullptr ; // unused
5252}
@@ -59,11 +59,11 @@ std::optional<core::T_sp> WeakPointer::value() const {
5959}
6060std::optional<core::T_sp> WeakPointer::value_no_lock () const {
6161 if (_value || !_splattablep)
62- return core::T_sp ( _value) ;
62+ return _value;
6363 else return std::nullopt ;
6464}
6565void WeakPointer::store_no_lock (core::T_sp o) {
66- _value = o. tagged_ () ;
66+ _value = o;
6767 _splattablep = o.objectp ();
6868 // links set up in fixupInternals below.
6969}
@@ -76,31 +76,30 @@ void WeakPointer::store(core::T_sp o) {
7676 _splattablep = false ;
7777 GC_unregister_disappearing_link ((void **)&_value);
7878 }
79- _value = o. tagged_ () ;
79+ _value = o;
8080}
8181
8282void WeakPointer::fixupInternalsForSnapshotSaveLoad (snapshotSaveLoad::Fixup* fixup) {
8383 if (snapshotSaveLoad::operation (fixup) == snapshotSaveLoad::LoadOp) {
8484 // We do this later rather than in store_no_lock because register/deregister
8585 // unconditionally grab a lock. This is a bit of a KLUDGE.
86- core::T_sp o (_value);
87- if (o.objectp ()) {
86+ if (_value.objectp ()) {
8887 _splattablep = true ;
8988 // Implicitly removes any previous registration, per boehm docs.
90- GC_general_register_disappearing_link ((void **)&_value, &*o );
89+ GC_general_register_disappearing_link ((void **)&_value, &*_value );
9190 } else {
9291 _splattablep = false ;
9392 GC_unregister_disappearing_link ((void **)&_value);
9493 }
9594 }
9695}
9796#else // not-actually-weak pointers - TODO for your other GC!
98- WeakPointer::WeakPointer (core::T_sp o) : _value(o.tagged_() ) {}
97+ WeakPointer::WeakPointer (core::T_sp o) : _value(o) {}
9998
10099// always valid
101- std::optional<core::T_sp> WeakPointer::value () const { return core::T_sp ( _value) ; }
100+ std::optional<core::T_sp> WeakPointer::value () const { return _value; }
102101std::optional<core::T_sp> WeakPointer::value_no_lock () const { return value (); }
103- void WeakPointer::store_no_lock (core::T_sp o) { _value = o. tagged_ () ; }
102+ void WeakPointer::store_no_lock (core::T_sp o) { _value = o; }
104103void WeakPointer::store (core::T_sp o) { store_no_lock (o); }
105104void WeakPointer::fixupInternalsForSnapshotSaveLoad (snapshotSaveLoad::Fixup*) {}
106105#endif
0 commit comments