summaryrefslogtreecommitdiff
path: root/qpid/cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2009-05-07 19:48:28 +0000
committerAlan Conway <aconway@apache.org>2009-05-07 19:48:28 +0000
commitd8e4daad8096ace9de64f18e6ae7740455a1c2b6 (patch)
tree24d2f2037b9d91485cdeef8dda0e6e2e05382058 /qpid/cpp
parent46c0d085d7d2b790f5ada87b9bb9b679233db90f (diff)
downloadqpid-python-d8e4daad8096ace9de64f18e6ae7740455a1c2b6.tar.gz
Use set for efficient insert/remove rather than list.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@772752 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp')
-rw-r--r--qpid/cpp/src/qpid/broker/QueueListeners.cpp26
-rw-r--r--qpid/cpp/src/qpid/broker/QueueListeners.h8
2 files changed, 9 insertions, 25 deletions
diff --git a/qpid/cpp/src/qpid/broker/QueueListeners.cpp b/qpid/cpp/src/qpid/broker/QueueListeners.cpp
index 7baca7d0f4..5b2c898294 100644
--- a/qpid/cpp/src/qpid/broker/QueueListeners.cpp
+++ b/qpid/cpp/src/qpid/broker/QueueListeners.cpp
@@ -27,43 +27,31 @@ namespace broker {
void QueueListeners::addListener(Consumer::shared_ptr c)
{
if (c->preAcquires()) {
- add(consumers, c);
+ consumers.insert(c);
} else {
- add(browsers, c);
+ browsers.insert(c);
}
}
void QueueListeners::removeListener(Consumer::shared_ptr c)
{
if (c->preAcquires()) {
- remove(consumers, c);
+ consumers.erase(c);
} else {
- remove(browsers, c);
+ browsers.erase(c);
}
}
void QueueListeners::populate(NotificationSet& set)
{
- if (consumers.size()) {
- set.consumer = consumers.front();
- consumers.pop_front();
+ if (!consumers.empty()) {
+ set.consumer = *consumers.begin();
+ consumers.erase(consumers.begin());
} else {
browsers.swap(set.browsers);
}
}
-void QueueListeners::add(Listeners& listeners, Consumer::shared_ptr c)
-{
- Listeners::iterator i = std::find(listeners.begin(), listeners.end(), c);
- if (i == listeners.end()) listeners.push_back(c);
-}
-
-void QueueListeners::remove(Listeners& listeners, Consumer::shared_ptr c)
-{
- Listeners::iterator i = std::find(listeners.begin(), listeners.end(), c);
- if (i != listeners.end()) listeners.erase(i);
-}
-
void QueueListeners::NotificationSet::notify()
{
if (consumer) consumer->notify();
diff --git a/qpid/cpp/src/qpid/broker/QueueListeners.h b/qpid/cpp/src/qpid/broker/QueueListeners.h
index 53ed6a17e4..509f1be6f3 100644
--- a/qpid/cpp/src/qpid/broker/QueueListeners.h
+++ b/qpid/cpp/src/qpid/broker/QueueListeners.h
@@ -22,7 +22,7 @@
*
*/
#include "Consumer.h"
-#include <list>
+#include <set>
namespace qpid {
namespace broker {
@@ -40,7 +40,7 @@ namespace broker {
class QueueListeners
{
public:
- typedef std::list<Consumer::shared_ptr> Listeners;
+ typedef std::set<Consumer::shared_ptr> Listeners;
class NotificationSet
{
@@ -58,10 +58,6 @@ class QueueListeners
private:
Listeners consumers;
Listeners browsers;
-
- void add(Listeners&, Consumer::shared_ptr);
- void remove(Listeners&, Consumer::shared_ptr);
-
};
}} // namespace qpid::broker