mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-03 16:30:29 +00:00
Minor cleanup
Put a noexcept annotation on drop_shared (since dispose is also noexcept for now) and simplify reset, fixing a bug in weak_ptr::swap.
This commit is contained in:
parent
f138d80c29
commit
72a9984055
1 changed files with 4 additions and 10 deletions
|
@ -72,7 +72,7 @@ class shared_ref
|
||||||
incref(&shared);
|
incref(&shared);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drop_shared()
|
void drop_shared() noexcept
|
||||||
{
|
{
|
||||||
if (decref(&shared)) {
|
if (decref(&shared)) {
|
||||||
dispose();
|
dispose();
|
||||||
|
@ -281,11 +281,7 @@ class shared_ptr
|
||||||
|
|
||||||
void reset() noexcept
|
void reset() noexcept
|
||||||
{
|
{
|
||||||
if (rc) {
|
shared_ptr().swap(*this);
|
||||||
rc->drop_shared();
|
|
||||||
}
|
|
||||||
p = nullptr;
|
|
||||||
rc = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename U>
|
template<typename U>
|
||||||
|
@ -398,14 +394,12 @@ class weak_ptr
|
||||||
|
|
||||||
void reset() noexcept
|
void reset() noexcept
|
||||||
{
|
{
|
||||||
if (rc)
|
weak_ptr().swap(*this);
|
||||||
rc->drop_weak();
|
|
||||||
p = nullptr;
|
|
||||||
rc = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void swap(weak_ptr& r) noexcept
|
void swap(weak_ptr& r) noexcept
|
||||||
{
|
{
|
||||||
|
using ctl::swap;
|
||||||
swap(p, r.p);
|
swap(p, r.p);
|
||||||
swap(rc, r.rc);
|
swap(rc, r.rc);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue