mirror of
https://github.com/boostorg/json.git
synced 2026-02-15 13:12:17 +00:00
Move some storage_ptr definitions:
The destructor and move constructor definitions are moved to the header file to allow the compiler to still optimize some array and object operations when whole program optimization is not turned on.
This commit is contained in:
@@ -80,8 +80,11 @@ struct object::element
|
||||
p[sizeof(element) +
|
||||
n + key.size()] = '\0';
|
||||
boost::ignore_unused(e);
|
||||
#if 0
|
||||
// VFALCO This causes unnecessary addref/release
|
||||
BOOST_ASSERT(
|
||||
*e->v_.get_storage() == *sp);
|
||||
#endif
|
||||
return reinterpret_cast<element*>(p);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,26 +12,12 @@
|
||||
|
||||
#include <boost/json/storage.hpp>
|
||||
#include <boost/json/detail/storage_adaptor.hpp>
|
||||
#include <boost/core/exchange.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace boost {
|
||||
namespace json {
|
||||
|
||||
storage_ptr::
|
||||
~storage_ptr()
|
||||
{
|
||||
if(p_)
|
||||
p_->release();
|
||||
}
|
||||
|
||||
storage_ptr::
|
||||
storage_ptr(storage_ptr&& other) noexcept
|
||||
: p_(boost::exchange(other.p_, nullptr))
|
||||
{
|
||||
}
|
||||
|
||||
storage_ptr::
|
||||
storage_ptr(storage_ptr const& other) noexcept
|
||||
: p_(other.p_)
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#define BOOST_JSON_STORAGE_HPP
|
||||
|
||||
#include <boost/json/detail/config.hpp>
|
||||
#include <boost/core/exchange.hpp>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <type_traits>
|
||||
@@ -86,11 +87,17 @@ class storage_ptr
|
||||
public:
|
||||
storage_ptr() = default;
|
||||
|
||||
BOOST_JSON_DECL
|
||||
~storage_ptr();
|
||||
~storage_ptr()
|
||||
{
|
||||
if(p_)
|
||||
p_->release();
|
||||
}
|
||||
|
||||
BOOST_JSON_DECL
|
||||
storage_ptr(storage_ptr&&) noexcept;
|
||||
storage_ptr(storage_ptr&& other) noexcept
|
||||
: p_(boost::exchange(
|
||||
other.p_, nullptr))
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_JSON_DECL
|
||||
storage_ptr(storage_ptr const&) noexcept;
|
||||
|
||||
Reference in New Issue
Block a user