aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-01-19 00:42:44 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-01-19 00:42:44 +0000
commitc36bffdd89a43a08f7b44a6527462b4a9de2d1b1 (patch)
tree97db076145585a5e90d68f41144a4896fa8adfa6
parentb12a4f151e0c16e18c08de5929922e4cd4d35165 (diff)
downloadpaludis-c36bffdd89a43a08f7b44a6527462b4a9de2d1b1.tar.gz
paludis-c36bffdd89a43a08f7b44a6527462b4a9de2d1b1.tar.xz
Avoid storing some duplicates
-rw-r--r--paludis/repositories/e/e_installed_repository_id.cc14
-rw-r--r--paludis/repositories/e/e_key.cc57
-rw-r--r--paludis/repositories/e/e_key.hh6
-rw-r--r--paludis/repositories/e/ebuild.cc10
-rw-r--r--paludis/repositories/e/ebuild_flat_metadata_cache.cc27
-rw-r--r--paludis/repositories/e/ebuild_id.cc20
-rw-r--r--paludis/repositories/e/ebuild_id.hh10
7 files changed, 56 insertions, 88 deletions
diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc
index f05cd82..6c3791d 100644
--- a/paludis/repositories/e/e_installed_repository_id.cc
+++ b/paludis/repositories/e/e_installed_repository_id.cc
@@ -255,7 +255,7 @@ EInstalledRepositoryID::need_keys_added() const
if (! vars->license()->name().empty())
if ((_imp->dir / vars->license()->name()).exists())
{
- _imp->license.reset(new ELicenseKey(_imp->environment, shared_from_this(), vars->license()->name(), vars->license()->description(),
+ _imp->license.reset(new ELicenseKey(_imp->environment, shared_from_this(), vars->license(),
file_contents(_imp->dir / vars->license()->name()), mkt_normal));
add_metadata_key(_imp->license);
}
@@ -321,8 +321,7 @@ EInstalledRepositoryID::need_keys_added() const
if (! vars->restrictions()->name().empty())
if ((_imp->dir / vars->restrictions()->name()).exists())
{
- _imp->restrictions.reset(new EPlainTextSpecKey(_imp->environment, shared_from_this(), vars->restrictions()->name(),
- vars->restrictions()->description(),
+ _imp->restrictions.reset(new EPlainTextSpecKey(_imp->environment, shared_from_this(), vars->restrictions(),
file_contents(_imp->dir / vars->restrictions()->name()), mkt_internal));
add_metadata_key(_imp->restrictions);
}
@@ -330,8 +329,7 @@ EInstalledRepositoryID::need_keys_added() const
if (! vars->properties()->name().empty())
if ((_imp->dir / vars->properties()->name()).exists())
{
- _imp->properties.reset(new EPlainTextSpecKey(_imp->environment, shared_from_this(), vars->properties()->name(),
- vars->properties()->description(),
+ _imp->properties.reset(new EPlainTextSpecKey(_imp->environment, shared_from_this(), vars->properties(),
file_contents(_imp->dir / vars->properties()->name()), mkt_internal));
add_metadata_key(_imp->properties);
}
@@ -410,8 +408,7 @@ EInstalledRepositoryID::need_keys_added() const
if (! value.empty())
{
_imp->bugs_to.reset(new EPlainTextSpecKey(_imp->environment, shared_from_this(),
- vars->bugs_to()->name(),
- vars->bugs_to()->description(), value, mkt_normal));
+ vars->bugs_to(), value, mkt_normal));
add_metadata_key(_imp->bugs_to);
}
}
@@ -423,8 +420,7 @@ EInstalledRepositoryID::need_keys_added() const
if (! value.empty())
{
_imp->remote_ids.reset(new EPlainTextSpecKey(_imp->environment, shared_from_this(),
- vars->remote_ids()->name(),
- vars->remote_ids()->description(), value, mkt_internal));
+ vars->remote_ids(), value, mkt_internal));
add_metadata_key(_imp->remote_ids);
}
}
diff --git a/paludis/repositories/e/e_key.cc b/paludis/repositories/e/e_key.cc
index e72c141..613607e 100644
--- a/paludis/repositories/e/e_key.cc
+++ b/paludis/repositories/e/e_key.cc
@@ -108,7 +108,6 @@ namespace paludis
const std::string string_value;
mutable Mutex value_mutex;
mutable std::tr1::shared_ptr<const DependencySpecTree> value;
- mutable std::tr1::function<void () throw ()> value_used;
const std::tr1::shared_ptr<const DependencyLabelSequence> labels;
const std::string raw_name;
@@ -150,14 +149,7 @@ EDependenciesKey::value() const
{
Lock l(_imp->value_mutex);
if (_imp->value)
- {
- if (_imp->value_used)
- {
- _imp->value_used();
- _imp->value_used = std::tr1::function<void () throw ()>();
- }
return _imp->value;
- }
Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
_imp->value = parse_depend(_imp->string_value, _imp->env, _imp->id, *_imp->id->eapi());
@@ -216,20 +208,17 @@ namespace paludis
const std::string string_value;
mutable Mutex value_mutex;
mutable std::tr1::shared_ptr<const LicenseSpecTree> value;
- mutable std::tr1::function<void () throw ()> value_used;
- const std::string raw_name;
- const std::string human_name;
+ const std::tr1::shared_ptr<const EAPIMetadataVariable> variable;
const MetadataKeyType type;
Implementation(const Environment * const e,
const std::tr1::shared_ptr<const ERepositoryID> & i, const std::string & v,
- const std::string & r, const std::string & h, const MetadataKeyType t) :
+ const std::tr1::shared_ptr<const EAPIMetadataVariable> & m, const MetadataKeyType t) :
env(e),
id(i),
string_value(v),
- raw_name(r),
- human_name(h),
+ variable(m),
type(t)
{
}
@@ -239,8 +228,8 @@ namespace paludis
ELicenseKey::ELicenseKey(
const Environment * const e,
const std::tr1::shared_ptr<const ERepositoryID> & id,
- const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
- PrivateImplementationPattern<ELicenseKey>(new Implementation<ELicenseKey>(e, id, v, r, h, t))
+ const std::tr1::shared_ptr<const EAPIMetadataVariable> & m, const std::string & v, const MetadataKeyType t) :
+ PrivateImplementationPattern<ELicenseKey>(new Implementation<ELicenseKey>(e, id, v, m, t))
{
}
@@ -253,14 +242,7 @@ ELicenseKey::value() const
{
Lock l(_imp->value_mutex);
if (_imp->value)
- {
- if (_imp->value_used)
- {
- _imp->value_used();
- _imp->value_used = std::tr1::function<void () throw ()>();
- }
return _imp->value;
- }
Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
_imp->value = parse_license(_imp->string_value, _imp->env, _imp->id, *_imp->id->eapi());
@@ -288,13 +270,13 @@ ELicenseKey::pretty_print_flat(const LicenseSpecTree::ItemFormatter & f) const
const std::string
ELicenseKey::raw_name() const
{
- return _imp->raw_name;
+ return _imp->variable->name();
}
const std::string
ELicenseKey::human_name() const
{
- return _imp->human_name;
+ return _imp->variable->description();
}
MetadataKeyType
@@ -527,17 +509,16 @@ namespace paludis
mutable Mutex value_mutex;
mutable std::tr1::shared_ptr<const PlainTextSpecTree> value;
- const std::string raw_name;
- const std::string human_name;
+ const std::tr1::shared_ptr<const EAPIMetadataVariable> variable;
const MetadataKeyType type;
Implementation(const Environment * const e, const std::tr1::shared_ptr<const ERepositoryID> & i, const std::string & v,
- const std::string & r, const std::string & h, const MetadataKeyType t) :
+ const std::tr1::shared_ptr<const EAPIMetadataVariable> & m,
+ const MetadataKeyType t) :
env(e),
id(i),
string_value(v),
- raw_name(r),
- human_name(h),
+ variable(m),
type(t)
{
}
@@ -546,8 +527,8 @@ namespace paludis
EPlainTextSpecKey::EPlainTextSpecKey(const Environment * const e,
const std::tr1::shared_ptr<const ERepositoryID> & id,
- const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
- PrivateImplementationPattern<EPlainTextSpecKey>(new Implementation<EPlainTextSpecKey>(e, id, v, r, h, t))
+ const std::tr1::shared_ptr<const EAPIMetadataVariable> & m, const std::string & v, const MetadataKeyType t) :
+ PrivateImplementationPattern<EPlainTextSpecKey>(new Implementation<EPlainTextSpecKey>(e, id, v, m, t))
{
}
@@ -589,13 +570,13 @@ EPlainTextSpecKey::pretty_print_flat(const PlainTextSpecTree::ItemFormatter & f)
const std::string
EPlainTextSpecKey::raw_name() const
{
- return _imp->raw_name;
+ return _imp->variable->name();
}
const std::string
EPlainTextSpecKey::human_name() const
{
- return _imp->human_name;
+ return _imp->variable->description();
}
MetadataKeyType
@@ -789,7 +770,6 @@ namespace paludis
const std::string string_value;
mutable Mutex value_mutex;
mutable std::tr1::shared_ptr<KeywordNameSet> value;
- mutable std::tr1::function<void () throw ()> value_used;
const std::string raw_name;
const std::string human_name;
@@ -823,14 +803,7 @@ EKeywordsKey::value() const
{
Lock l(_imp->value_mutex);
if (_imp->value)
- {
- if (_imp->value_used)
- {
- _imp->value_used();
- _imp->value_used = std::tr1::function<void () throw ()>();
- }
return _imp->value;
- }
_imp->value.reset(new KeywordNameSet);
Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
diff --git a/paludis/repositories/e/e_key.hh b/paludis/repositories/e/e_key.hh
index 65e830b..0cb4409 100644
--- a/paludis/repositories/e/e_key.hh
+++ b/paludis/repositories/e/e_key.hh
@@ -148,7 +148,8 @@ namespace paludis
public:
EPlainTextSpecKey(const Environment * const,
const std::tr1::shared_ptr<const ERepositoryID> &,
- const std::string &, const std::string &, const std::string &, const MetadataKeyType);
+ const std::tr1::shared_ptr<const EAPIMetadataVariable> &,
+ const std::string &, const MetadataKeyType);
~EPlainTextSpecKey();
virtual const std::tr1::shared_ptr<const PlainTextSpecTree> value() const
@@ -221,7 +222,8 @@ namespace paludis
ELicenseKey(
const Environment * const,
const std::tr1::shared_ptr<const ERepositoryID> &,
- const std::string &, const std::string &, const std::string &, const MetadataKeyType);
+ const std::tr1::shared_ptr<const EAPIMetadataVariable> &,
+ const std::string &, const MetadataKeyType);
~ELicenseKey();
virtual const std::tr1::shared_ptr<const LicenseSpecTree> value() const
diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc
index bc854a4..3406b89 100644
--- a/paludis/repositories/e/ebuild.cc
+++ b/paludis/repositories/e/ebuild.cc
@@ -496,7 +496,7 @@ EbuildMetadataCommand::load(const std::tr1::shared_ptr<const EbuildID> & id)
id->load_homepage(m.homepage()->name(), m.homepage()->description(), get(keys, m.homepage()->name()));
if (! m.license()->name().empty())
- id->load_license(m.license()->name(), m.license()->description(), get(keys, m.license()->name()));
+ id->load_license(m.license(), get(keys, m.license()->name()));
if (! m.provide()->name().empty())
id->load_provide(m.provide()->name(), m.provide()->description(), get(keys, m.provide()->name()));
@@ -514,10 +514,10 @@ EbuildMetadataCommand::load(const std::tr1::shared_ptr<const EbuildID> & id)
id->load_keywords(m.keywords()->name(), m.keywords()->description(), get(keys, m.keywords()->name()));
if (! m.restrictions()->name().empty())
- id->load_restrict(m.restrictions()->name(), m.restrictions()->description(), get(keys, m.restrictions()->name()));
+ id->load_restrict(m.restrictions(), get(keys, m.restrictions()->name()));
if (! m.properties()->name().empty())
- id->load_properties(m.properties()->name(), m.properties()->description(), get(keys, m.properties()->name()));
+ id->load_properties(m.properties(), get(keys, m.properties()->name()));
if (! m.use()->name().empty())
id->load_use(m.use()->name(), m.use()->description(), get(keys, m.use()->name()));
@@ -547,14 +547,14 @@ EbuildMetadataCommand::load(const std::tr1::shared_ptr<const EbuildID> & id)
{
std::string value(get(keys, m.bugs_to()->name()));
if (! value.empty())
- id->load_bugs_to(m.bugs_to()->name(), m.bugs_to()->description(), value);
+ id->load_bugs_to(m.bugs_to(), value);
}
if (! m.remote_ids()->name().empty())
{
std::string value(get(keys, m.remote_ids()->name()));
if (! value.empty())
- id->load_remote_ids(m.remote_ids()->name(), m.remote_ids()->description(), value);
+ id->load_remote_ids(m.remote_ids(), value);
}
if (! m.defined_phases()->name().empty())
diff --git a/paludis/repositories/e/ebuild_flat_metadata_cache.cc b/paludis/repositories/e/ebuild_flat_metadata_cache.cc
index 493dcf2..6472b50 100644
--- a/paludis/repositories/e/ebuild_flat_metadata_cache.cc
+++ b/paludis/repositories/e/ebuild_flat_metadata_cache.cc
@@ -181,16 +181,16 @@ namespace
id->load_src_uri(m.src_uri(), lines.at(m.src_uri()->flat_list_index()));
if (-1 != m.restrictions()->flat_list_index() && ! m.restrictions()->name().empty())
- id->load_restrict(m.restrictions()->name(), m.restrictions()->description(), lines.at(m.restrictions()->flat_list_index()));
+ id->load_restrict(m.restrictions(), lines.at(m.restrictions()->flat_list_index()));
if (-1 != m.properties()->flat_list_index() && ! m.properties()->name().empty())
- id->load_properties(m.properties()->name(), m.properties()->description(), lines.at(m.properties()->flat_list_index()));
+ id->load_properties(m.properties(), lines.at(m.properties()->flat_list_index()));
if (-1 != m.homepage()->flat_list_index() && ! m.homepage()->name().empty())
id->load_homepage(m.homepage()->name(), m.homepage()->description(), lines.at(m.homepage()->flat_list_index()));
if (-1 != m.license()->flat_list_index() && ! m.license()->name().empty())
- id->load_license(m.license()->name(), m.license()->description(), lines.at(m.license()->flat_list_index()));
+ id->load_license(m.license(), lines.at(m.license()->flat_list_index()));
if (-1 != m.short_description()->flat_list_index() && ! m.short_description()->name().empty())
id->load_short_description(m.short_description()->name(),
@@ -213,7 +213,8 @@ namespace
if (-1 != m.defined_phases()->flat_list_index() && ! m.defined_phases()->name().empty())
if (! lines.at(m.defined_phases()->flat_list_index()).empty())
- id->load_defined_phases(m.defined_phases()->name(), m.defined_phases()->description(), lines.at(m.defined_phases()->flat_list_index()));
+ id->load_defined_phases(m.defined_phases()->name(), m.defined_phases()->description(),
+ lines.at(m.defined_phases()->flat_list_index()));
if (-1 != m.iuse()->flat_list_index() && ! m.iuse()->name().empty())
id->load_iuse(m.iuse()->name(), m.iuse()->description(), lines.at(m.iuse()->flat_list_index()));
@@ -258,16 +259,14 @@ namespace
{
std::string value(lines.at(m.bugs_to()->flat_list_index()));
if (! value.empty())
- id->load_bugs_to(m.bugs_to()->name(),
- m.bugs_to()->description(), value);
+ id->load_bugs_to(m.bugs_to(), value);
}
if (-1 != m.remote_ids()->flat_list_index() && ! m.remote_ids()->name().empty())
{
std::string value(lines.at(m.remote_ids()->flat_list_index()));
if (! value.empty())
- id->load_remote_ids(m.remote_ids()->name(),
- m.remote_ids()->description(), value);
+ id->load_remote_ids(m.remote_ids(), value);
}
}
else
@@ -495,16 +494,16 @@ EbuildFlatMetadataCache::load(const std::tr1::shared_ptr<const EbuildID> & id)
id->load_src_uri(m.src_uri(), keys[m.src_uri()->name()]);
if (! m.restrictions()->name().empty())
- id->load_restrict(m.restrictions()->name(), m.restrictions()->description(), keys[m.restrictions()->name()]);
+ id->load_restrict(m.restrictions(), keys[m.restrictions()->name()]);
if (! m.properties()->name().empty())
- id->load_properties(m.properties()->name(), m.properties()->description(), keys[m.properties()->name()]);
+ id->load_properties(m.properties(), keys[m.properties()->name()]);
if (! m.homepage()->name().empty())
id->load_homepage(m.homepage()->name(), m.homepage()->description(), keys[m.homepage()->name()]);
if (! m.license()->name().empty())
- id->load_license(m.license()->name(), m.license()->description(), keys[m.license()->name()]);
+ id->load_license(m.license(), keys[m.license()->name()]);
if (! m.short_description()->name().empty())
id->load_short_description(m.short_description()->name(),
@@ -586,16 +585,14 @@ EbuildFlatMetadataCache::load(const std::tr1::shared_ptr<const EbuildID> & id)
{
std::string value(keys[m.bugs_to()->name()]);
if (! value.empty())
- id->load_bugs_to(m.bugs_to()->name(),
- m.bugs_to()->description(), value);
+ id->load_bugs_to(m.bugs_to(), value);
}
if (! m.remote_ids()->name().empty())
{
std::string value(keys[m.remote_ids()->name()]);
if (! value.empty())
- id->load_remote_ids(m.remote_ids()->name(),
- m.remote_ids()->description(), value);
+ id->load_remote_ids(m.remote_ids(), value);
}
}
else
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index 0976475..db3bbef 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -858,26 +858,26 @@ EbuildID::load_homepage(const std::string & r, const std::string & h, const std:
}
void
-EbuildID::load_license(const std::string & r, const std::string & h, const std::string & v) const
+EbuildID::load_license(const std::tr1::shared_ptr<const EAPIMetadataVariable> & m, const std::string & v) const
{
Lock l(_imp->mutex);
- _imp->license.reset(new ELicenseKey(_imp->environment, shared_from_this(), r, h, v, mkt_internal));
+ _imp->license.reset(new ELicenseKey(_imp->environment, shared_from_this(), m, v, mkt_internal));
add_metadata_key(_imp->license);
}
void
-EbuildID::load_restrict(const std::string & r, const std::string & h, const std::string & v) const
+EbuildID::load_restrict(const std::tr1::shared_ptr<const EAPIMetadataVariable> & m, const std::string & v) const
{
Lock l(_imp->mutex);
- _imp->restrictions.reset(new EPlainTextSpecKey(_imp->environment, shared_from_this(), r, h, v, mkt_internal));
+ _imp->restrictions.reset(new EPlainTextSpecKey(_imp->environment, shared_from_this(), m, v, mkt_internal));
add_metadata_key(_imp->restrictions);
}
void
-EbuildID::load_properties(const std::string & r, const std::string & h, const std::string & v) const
+EbuildID::load_properties(const std::tr1::shared_ptr<const EAPIMetadataVariable> & m, const std::string & v) const
{
Lock l(_imp->mutex);
- _imp->properties.reset(new EPlainTextSpecKey(_imp->environment, shared_from_this(), r, h, v, mkt_internal));
+ _imp->properties.reset(new EPlainTextSpecKey(_imp->environment, shared_from_this(), m, v, mkt_internal));
add_metadata_key(_imp->properties);
}
@@ -965,18 +965,18 @@ EbuildID::load_upstream_release_notes(const std::string & r, const std::string &
}
void
-EbuildID::load_bugs_to(const std::string & r, const std::string & h, const std::string & v) const
+EbuildID::load_bugs_to(const std::tr1::shared_ptr<const EAPIMetadataVariable> & m, const std::string & v) const
{
Lock l(_imp->mutex);
- _imp->bugs_to.reset(new EPlainTextSpecKey(_imp->environment, shared_from_this(), r, h, v, mkt_normal));
+ _imp->bugs_to.reset(new EPlainTextSpecKey(_imp->environment, shared_from_this(), m, v, mkt_normal));
add_metadata_key(_imp->bugs_to);
}
void
-EbuildID::load_remote_ids(const std::string & r, const std::string & h, const std::string & v) const
+EbuildID::load_remote_ids(const std::tr1::shared_ptr<const EAPIMetadataVariable> & m, const std::string & v) const
{
Lock l(_imp->mutex);
- _imp->remote_ids.reset(new EPlainTextSpecKey(_imp->environment, shared_from_this(), r, h, v, mkt_internal));
+ _imp->remote_ids.reset(new EPlainTextSpecKey(_imp->environment, shared_from_this(), m, v, mkt_internal));
add_metadata_key(_imp->remote_ids);
}
diff --git a/paludis/repositories/e/ebuild_id.hh b/paludis/repositories/e/ebuild_id.hh
index b6461f6..3694ceb 100644
--- a/paludis/repositories/e/ebuild_id.hh
+++ b/paludis/repositories/e/ebuild_id.hh
@@ -120,21 +120,21 @@ namespace paludis
void load_post_depend(const std::string &, const std::string &, const std::string &) const;
void load_src_uri(const std::tr1::shared_ptr<const EAPIMetadataVariable> &, const std::string &) const;
void load_homepage(const std::string &, const std::string &, const std::string &) const;
- void load_license(const std::string &, const std::string &, const std::string &) const;
+ void load_license(const std::tr1::shared_ptr<const EAPIMetadataVariable> &, const std::string &) const;
void load_provide(const std::string &, const std::string &, const std::string &) const;
void load_iuse(const std::string &, const std::string &, const std::string &) const;
void load_myoptions(const std::string &, const std::string &, const std::string &) const;
void load_use(const std::string &, const std::string &, const std::string &) const;
void load_inherited(const std::string &, const std::string &, const std::string &) const;
void load_keywords(const std::string &, const std::string &, const std::string &) const;
- void load_restrict(const std::string &, const std::string &, const std::string &) const;
- void load_properties(const std::string &, const std::string &, const std::string &) const;
+ void load_restrict(const std::tr1::shared_ptr<const EAPIMetadataVariable> & m, const std::string & v) const;
+ void load_properties(const std::tr1::shared_ptr<const EAPIMetadataVariable> & m, const std::string &) const;
void load_long_description(const std::string &, const std::string &, const std::string &) const;
void load_upstream_changelog(const std::string &, const std::string &, const std::string &) const;
void load_upstream_documentation(const std::string &, const std::string &, const std::string &) const;
void load_upstream_release_notes(const std::string &, const std::string &, const std::string &) const;
- void load_bugs_to(const std::string &, const std::string &, const std::string &) const;
- void load_remote_ids(const std::string &, const std::string &, const std::string &) const;
+ void load_bugs_to(const std::tr1::shared_ptr<const EAPIMetadataVariable> &, const std::string &) const;
+ void load_remote_ids(const std::tr1::shared_ptr<const EAPIMetadataVariable> &, const std::string &) const;
void load_defined_phases(const std::string &, const std::string &, const std::string &) const;
virtual bool supports_action(const SupportsActionTestBase &) const PALUDIS_ATTRIBUTE((warn_unused_result));