From d6afc013bf0b8950ffab84ccd3b9c8a5c68bab98 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Thu, 30 Jul 2015 10:20:28 +0300 Subject: [PATCH] Optimized refcount variable importing methods --- include/boost/dll/import_variable.hpp | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/include/boost/dll/import_variable.hpp b/include/boost/dll/import_variable.hpp index ea9530b..357b0a4 100644 --- a/include/boost/dll/import_variable.hpp +++ b/include/boost/dll/import_variable.hpp @@ -1,4 +1,5 @@ // Copyright 2014 Renato Tegon Forti, Antony Polukhin. +// Copyright 2015 Antony Polukhin. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt @@ -21,27 +22,12 @@ /// functions that hold a shared pointer to the instance of /// boost::dll::shared_library. -namespace boost { namespace dll { - -namespace detail { - struct ptr_holding_empty_deleter { - boost::shared_ptr lib_; - - explicit ptr_holding_empty_deleter(const boost::shared_ptr& lib) - : lib_(lib) - {} - - inline void operator()(const void*) const BOOST_NOEXCEPT { /*do nothing*/ } - }; -} // namespace detail - -namespace explicit_api { - +namespace boost { namespace dll { namespace explicit_api { //! \overload boost::dll::import_variable(const boost::shared_ptr& lib, boost::string_ref variable_name, load_mode::type mode) template boost::shared_ptr import_variable(const boost::shared_ptr& lib, boost::string_ref variable_name) { - return boost::shared_ptr(&lib->get(variable_name), boost::dll::detail::ptr_holding_empty_deleter(lib)); + return boost::shared_ptr(lib, &lib->get(variable_name)); } /*! @@ -97,7 +83,7 @@ boost::shared_ptr import_variable(const boost::filesystem::path& lib, boost:: //! \overload boost::dll::import_variable_alias(const boost::shared_ptr& lib, boost::string_ref variable_name, load_mode::type mode) template boost::shared_ptr import_variable_alias(const boost::shared_ptr& lib, boost::string_ref variable_name) { - return boost::shared_ptr(lib->get(variable_name), boost::dll::detail::ptr_holding_empty_deleter(lib)); + return boost::shared_ptr(lib, lib->get(variable_name)); } /*!