2
0
mirror of https://github.com/boostorg/signals.git synced 2026-01-19 04:42:10 +00:00

Improve signal invocation performance, from Robert Zeh

[SVN r35432]
This commit is contained in:
Douglas Gregor
2006-09-30 13:46:07 +00:00
parent c0005c2de2
commit e551b054c3
5 changed files with 50 additions and 86 deletions

View File

@@ -60,7 +60,8 @@ public:
typedef const stored_group& first_argument_type;
typedef const stored_group& second_argument_type;
group_bridge_compare(const Compare& c) : comp(c) {}
group_bridge_compare(const Compare& c) : comp(c)
{ }
bool operator()(const stored_group& k1, const stored_group& k2) const
{
@@ -92,13 +93,39 @@ class BOOST_SIGNALS_DECL named_slot_map_iterator :
connection_slot_pair,
forward_traversal_tag> inherited;
public:
named_slot_map_iterator();
named_slot_map_iterator(const named_slot_map_iterator&);
named_slot_map_iterator& operator=(const named_slot_map_iterator&);
connection_slot_pair& dereference() const;
void increment();
bool equal(const named_slot_map_iterator& other) const;
named_slot_map_iterator() : slot_assigned(false)
{ }
named_slot_map_iterator(const named_slot_map_iterator& other)
: group(other.group), last_group(other.last_group),
slot_assigned(other.slot_assigned)
{
if (slot_assigned) slot_ = other.slot_;
}
named_slot_map_iterator& operator=(const named_slot_map_iterator& other)
{
slot_assigned = other.slot_assigned;
group = other.group;
last_group = other.last_group;
if (slot_assigned) slot_ = other.slot_;
return *this;
}
connection_slot_pair& dereference() const
{
return *slot_;
}
void increment()
{
++slot_;
if (slot_ == group->second.end()) {
++group;
init_next_group();
}
}
bool equal(const named_slot_map_iterator& other) const {
return (group == other.group
&& (group == last_group
|| slot_ == other.slot_));
}
#if BOOST_WORKAROUND(_MSC_VER, <= 1400)
void decrement();

View File

@@ -113,73 +113,50 @@ namespace BOOST_SIGNALS_NAMESPACE {
}
}
inline void add_if_trackable(const void*) const
{
}
inline void add_if_trackable(const void*) const { }
template<typename R>
inline void add_if_trackable(R (*)()) const
{
}
inline void add_if_trackable(R (*)()) const { }
template<typename R, typename T1>
inline void add_if_trackable(R (*)(T1)) const
{
}
inline void add_if_trackable(R (*)(T1)) const { }
template<typename R, typename T1, typename T2>
inline void add_if_trackable(R (*)(T1, T2)) const
{
}
inline void add_if_trackable(R (*)(T1, T2)) const { }
template<typename R, typename T1, typename T2, typename T3>
inline void add_if_trackable(R (*)(T1, T2, T3)) const
{
}
inline void add_if_trackable(R (*)(T1, T2, T3)) const { }
template<typename R, typename T1, typename T2, typename T3, typename T4>
inline void add_if_trackable(R (*)(T1, T2, T3, T4)) const
{
}
inline void add_if_trackable(R (*)(T1, T2, T3, T4)) const { }
template<typename R, typename T1, typename T2, typename T3, typename T4,
typename T5>
inline void add_if_trackable(R (*)(T1, T2, T3, T4, T5)) const
{
}
inline void add_if_trackable(R (*)(T1, T2, T3, T4, T5)) const { }
template<typename R, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6>
inline void add_if_trackable(R (*)(T1, T2, T3, T4, T5, T6)) const
{
}
inline void add_if_trackable(R (*)(T1, T2, T3, T4, T5, T6)) const { }
template<typename R, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7>
inline void add_if_trackable(R (*)(T1, T2, T3, T4, T5, T6, T7)) const
{
}
inline void add_if_trackable(R (*)(T1, T2, T3, T4, T5, T6, T7)) const { }
template<typename R, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8>
inline void add_if_trackable(R (*)(T1, T2, T3, T4, T5, T6, T7, T8)) const
{
}
inline void
add_if_trackable(R (*)(T1, T2, T3, T4, T5, T6, T7, T8)) const { }
template<typename R, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8, typename T9>
inline void
add_if_trackable(R (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9)) const
{
}
add_if_trackable(R (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9)) const { }
template<typename R, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8, typename T9,
typename T10>
inline void
add_if_trackable(R (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)) const
{
}
add_if_trackable(R (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)) const { }
std::vector<const trackable*>& bound_objects;
};

View File

@@ -23,46 +23,6 @@ typedef std::map<stored_group, group_list, compare_type> slot_container_type;
typedef slot_container_type::iterator group_iterator;
typedef slot_container_type::const_iterator const_group_iterator;
named_slot_map_iterator::named_slot_map_iterator() : slot_assigned(false) {}
named_slot_map_iterator::
named_slot_map_iterator(const named_slot_map_iterator& other)
: group(other.group), last_group(other.last_group),
slot_assigned(other.slot_assigned)
{
if (slot_assigned) slot_ = other.slot_;
}
named_slot_map_iterator&
named_slot_map_iterator::operator=(const named_slot_map_iterator& other)
{
slot_assigned = other.slot_assigned;
group = other.group;
last_group = other.last_group;
if (slot_assigned) slot_ = other.slot_;
return *this;
}
connection_slot_pair& named_slot_map_iterator::dereference() const
{ return *slot_; }
void named_slot_map_iterator::increment()
{
++slot_;
if (slot_ == group->second.end()) {
++group;
init_next_group();
}
}
bool
named_slot_map_iterator::equal(const named_slot_map_iterator& other) const
{
return (group == other.group
&& (group == last_group
|| slot_ == other.slot_));
}
#if BOOST_WORKAROUND(_MSC_VER, <= 1400)
void named_slot_map_iterator::decrement() { assert(false); }

View File

@@ -1,6 +1,6 @@
// Boost.Signals library
// Copyright Douglas Gregor 2001-2003. Use, modification and
// Copyright (C) Douglas Gregor 2001-2006. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

View File

@@ -1,6 +1,6 @@
// Boost.Signals library
// Copyright Douglas Gregor 2001-2003. Use, modification and
// Copyright Douglas Gregor 2001-2006. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)