aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-10-25 05:36:49 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-10-25 05:36:49 +0000
commit6fd3c01597f7cbd1a223e64f1a5c0c31f38c85ae (patch)
treee1d7636d5cba34df910fcd2827002eac23063581
parentde5282e0d0694838560c4edb5f5ae8d4c42288a2 (diff)
downloadpaludis-6fd3c01597f7cbd1a223e64f1a5c0c31f38c85ae.tar.gz
paludis-6fd3c01597f7cbd1a223e64f1a5c0c31f38c85ae.tar.xz
Cache sets. Fixes: ticket:390
-rw-r--r--paludis/environments/paludis/paludis_environment.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc
index 55463ad..6b9088d 100644
--- a/paludis/environments/paludis/paludis_environment.cc
+++ b/paludis/environments/paludis/paludis_environment.cc
@@ -54,6 +54,7 @@
#include <functional>
#include <algorithm>
#include <list>
+#include <map>
using namespace paludis;
using namespace paludis::paludis_environment;
@@ -74,6 +75,9 @@ namespace paludis
tr1::shared_ptr<PackageDatabase> package_database;
+ mutable Mutex sets_mutex;
+ mutable std::map<SetName, tr1::shared_ptr<SetSpecTree::ConstItem> > sets;
+
Implementation(PaludisEnvironment * const e, tr1::shared_ptr<PaludisConfig> c) :
done_hooks(false),
config(c),
@@ -336,6 +340,12 @@ PaludisEnvironment::local_set(const SetName & s) const
{
Context context("When looking for package set '" + stringify(s) + "' in paludis environment:");
+ Lock l(_imp->sets_mutex);
+
+ std::map<SetName, tr1::shared_ptr<SetSpecTree::ConstItem> >::const_iterator i(_imp->sets.find(s));
+ if (i != _imp->sets.end())
+ return i->second;
+
FSEntry dir(FSEntry(_imp->config->config_dir()) / "sets");
tr1::shared_ptr<GeneralSetDepTag> tag(new GeneralSetDepTag(s, stringify(s) + ".conf"));
@@ -347,6 +357,8 @@ PaludisEnvironment::local_set(const SetName & s) const
.parse_mode(pds_pm_unspecific)
.tag(tag)
.environment(this));
+
+ _imp->sets.insert(std::make_pair(s, f.contents()));
return f.contents();
}
else if ((dir / (stringify(s) + ".conf")).exists())
@@ -357,10 +369,15 @@ PaludisEnvironment::local_set(const SetName & s) const
.parse_mode(pds_pm_unspecific)
.tag(tag)
.environment(this));
+
+ _imp->sets.insert(std::make_pair(s, f.contents()));
return f.contents();
}
else
+ {
+ _imp->sets.insert(std::make_pair(s, tr1::shared_ptr<SetSpecTree::ConstItem>()));
return tr1::shared_ptr<SetSpecTree::ConstItem>();
+ }
}
tr1::shared_ptr<const SetNameSet>