aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-04-17 14:50:51 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-04-17 14:50:51 +0000
commit5ddac55f7cdff0886560344a5391be2bde8bbf32 (patch)
treee95a3c45394125e4178ed4936c0c12979d74bab5
parentb3b70ba13b1c02390d7768ec3403530e52ddedfe (diff)
downloadpaludis-5ddac55f7cdff0886560344a5391be2bde8bbf32.tar.gz
paludis-5ddac55f7cdff0886560344a5391be2bde8bbf32.tar.xz
Overload stringify for Validated, giving a small speed-up.
-rw-r--r--paludis/package_database.cc4
-rw-r--r--paludis/util/stringify.hh13
2 files changed, 15 insertions, 2 deletions
diff --git a/paludis/package_database.cc b/paludis/package_database.cc
index ae6f2dc..1c878bd 100644
--- a/paludis/package_database.cc
+++ b/paludis/package_database.cc
@@ -110,8 +110,8 @@ AmbiguousPackageNameError::AmbiguousPackageNameError(const std::string & our_nam
_name_data(new NameData)
{
_name_data->name = our_name;
- std::transform(begin, end, std::back_inserter(_name_data->names),
- &stringify<typename std::iterator_traits<I_>::value_type>);
+ while (begin != end)
+ _name_data->names.push_back(stringify(*begin++));
}
AmbiguousPackageNameError::AmbiguousPackageNameError(const AmbiguousPackageNameError & other) :
diff --git a/paludis/util/stringify.hh b/paludis/util/stringify.hh
index 2421c33..cad30dc 100644
--- a/paludis/util/stringify.hh
+++ b/paludis/util/stringify.hh
@@ -22,6 +22,7 @@
#include <paludis/util/attributes.hh>
#include <paludis/util/tr1_memory.hh>
+#include <paludis/util/validated-fwd.hh>
#include <sstream>
#include <string>
@@ -189,6 +190,18 @@ namespace paludis
{
return std::string(item);
}
+
+ /**
+ * Convert item to a string (overload for Validated).
+ *
+ * \ingroup g_strings
+ */
+ template <typename D_, typename V_, bool c_, typename C_>
+ inline std::string
+ stringify(const Validated<D_, V_, c_, C_> & v)
+ {
+ return stringify(v.data());
+ }
}
#endif