summaryrefslogtreecommitdiff
path: root/src/plugin.cpp
diff options
context:
space:
mode:
authorErkin Bahceci <erkinbah@gmail.com>2008-09-07 08:18:55 -0500
committerErkin Bahceci <erkinbah@gmail.com>2008-09-07 08:18:55 -0500
commit8f0d337bb4bad91d5987d1d0df7474ea5d02033c (patch)
treeffd161b8154a90f5ef872814a55bcc37110ed698 /src/plugin.cpp
parentb31b675fbf3db99ca3d481259732645ce07944d7 (diff)
downloadmobileperf-8f0d337bb4bad91d5987d1d0df7474ea5d02033c.tar.gz
mobileperf-8f0d337bb4bad91d5987d1d0df7474ea5d02033c.tar.bz2
Use plugin and window maps for more efficient search.
Diffstat (limited to 'src/plugin.cpp')
-rw-r--r--src/plugin.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/plugin.cpp b/src/plugin.cpp
index d1e2e4a..287d5a9 100644
--- a/src/plugin.cpp
+++ b/src/plugin.cpp
@@ -36,6 +36,7 @@
#include <compiz-core.h>
#include <compobject.h>
+CompPlugin::Map pluginsMap;
std::list<CompPlugin *> plugins;
class CorePluginVTable : public CompPlugin::VTable
@@ -444,11 +445,10 @@ CompPlugin::objectFiniPlugins (CompObject *o)
CompPlugin *
CompPlugin::find (const char *name)
{
- foreach (CompPlugin *p, plugins)
- {
- if (strcmp (p->vTable->name (), name) == 0)
- return p;
- }
+ CompPlugin::Map::iterator it = pluginsMap.find (name);
+
+ if (it != pluginsMap.end ())
+ return it->second;
return NULL;
}
@@ -507,7 +507,12 @@ CompPlugin::load (const char *name)
bool
CompPlugin::push (CompPlugin *p)
{
- if (find (p->vTable->name ()))
+ const char *name = p->vTable->name ();
+
+ std::pair<CompPlugin::Map::iterator, bool> insertRet =
+ pluginsMap.insert (std::pair<const char *, CompPlugin *> (name, p));
+
+ if (!insertRet.second)
{
compLogMessage (NULL, "core", CompLogLevelWarn,
"Plugin '%s' already active",
@@ -521,8 +526,9 @@ CompPlugin::push (CompPlugin *p)
if (!initPlugin (p))
{
compLogMessage (NULL, "core", CompLogLevelError,
- "Couldn't activate plugin '%s'", p->vTable->name ());
+ "Couldn't activate plugin '%s'", name);
+ pluginsMap.erase (name);
plugins.pop_front ();
return false;
@@ -542,6 +548,8 @@ CompPlugin::pop (void)
if (!p)
return 0;
+ pluginsMap.erase (p->vTable->name ());
+
finiPlugin (p);
plugins.pop_front ();