aboutsummaryrefslogtreecommitdiffstats
path: root/src/db/upnp/upnpplib.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-13 22:05:45 +0100
committerMax Kellermann <max@duempel.org>2014-01-13 22:24:02 +0100
commitca43e634b5adfebdcb9c3c8f61cebf38d42827e0 (patch)
treefab541d75386417187052650dcee16eb5c48f3b4 /src/db/upnp/upnpplib.cxx
parent85324f80fe1d72a066cc49847815830080eb1bc3 (diff)
downloadmpd-ca43e634b5adfebdcb9c3c8f61cebf38d42827e0.tar.gz
mpd-ca43e634b5adfebdcb9c3c8f61cebf38d42827e0.tar.xz
mpd-ca43e634b5adfebdcb9c3c8f61cebf38d42827e0.zip
db/upnp: use std::function for the libupnp callback
Replaces the bloated std::map.
Diffstat (limited to 'src/db/upnp/upnpplib.cxx')
-rw-r--r--src/db/upnp/upnpplib.cxx16
1 files changed, 3 insertions, 13 deletions
diff --git a/src/db/upnp/upnpplib.cxx b/src/db/upnp/upnpplib.cxx
index d7c65ccf4..508315b26 100644
--- a/src/db/upnp/upnpplib.cxx
+++ b/src/db/upnp/upnpplib.cxx
@@ -65,15 +65,6 @@ LibUPnP::LibUPnP()
ixmlRelaxParser(1);
}
-void
-LibUPnP::registerHandler(Upnp_EventType et, Upnp_FunPtr handler, void *cookie)
-{
- if (handler == nullptr)
- m_handlers.erase(et);
- else
- m_handlers.emplace(et, Handler(handler, cookie));
-}
-
int
LibUPnP::o_callback(Upnp_EventType et, void* evp, void* cookie)
{
@@ -83,10 +74,9 @@ LibUPnP::o_callback(Upnp_EventType et, void* evp, void* cookie)
ulib = theLib;
}
- auto it = ulib->m_handlers.find(et);
- if (it != ulib->m_handlers.end()) {
- (it->second.handler)(et, evp, it->second.cookie);
- }
+ if (ulib->handler)
+ ulib->handler(et, evp);
+
return UPNP_E_SUCCESS;
}