summaryrefslogtreecommitdiffstats
path: root/src/util/unordered-containers.h
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2013-10-05 03:54:43 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2013-10-05 03:54:43 +0000
commit706294ff1fa82c86089221d8ee4a0d5bd032925a (patch)
tree4f57389a922f2cb3fdcec99cb21599580e954867 /src/util/unordered-containers.h
parentC++ (diff)
downloadinkscape-706294ff1fa82c86089221d8ee4a0d5bd032925a.tar.gz
inkscape-706294ff1fa82c86089221d8ee4a0d5bd032925a.zip
Rewrite the internals of the unit code for somewhat better performance
(bzr r12661)
Diffstat (limited to 'src/util/unordered-containers.h')
-rw-r--r--src/util/unordered-containers.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/util/unordered-containers.h b/src/util/unordered-containers.h
index 6f738f0ce..70d36c4dc 100644
--- a/src/util/unordered-containers.h
+++ b/src/util/unordered-containers.h
@@ -16,6 +16,8 @@
# include "config.h"
#endif
+#include <glibmm/ustring.h>
+
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#if defined(HAVE_TR1_UNORDERED_SET)
@@ -25,6 +27,17 @@
# define INK_UNORDERED_MAP std::tr1::unordered_map
# define INK_HASH std::tr1::hash
+namespace std {
+namespace tr1 {
+template <>
+struct hash<Glib::ustring> : public std::unary_function<Glib::ustring, std::size_t> {
+ std::size_t operator()(Glib::ustring const &s) const {
+ return hash<std::string>()(s.raw());
+ }
+};
+} // namespace tr1
+} // namespace std
+
#elif defined(HAVE_BOOST_UNORDERED_SET)
# include <boost/unordered_set.hpp>
# include <boost/unordered_map.hpp>
@@ -32,6 +45,15 @@
# define INK_UNORDERED_MAP boost::unordered_map
# define INK_HASH boost::hash
+namespace boost {
+template <>
+struct hash<Glib::ustring> : public std::unary_function<Glib::ustring, std::size_t> {
+ std::size_t operator()(Glib::ustring const &s) const {
+ return hash<std::string>()(s.raw());
+ }
+};
+} // namespace boost
+
#elif defined(HAVE_EXT_HASH_SET)
# include <functional>
@@ -54,6 +76,13 @@ struct hash<T *> : public std::unary_function<T *, std::size_t> {
return x + (x >> 3);
}
};
+
+template <>
+struct hash<Glib::ustring> : public std::unary_function<Glib::ustring, std::size_t> {
+ std::size_t operator()(Glib::ustring const &s) const {
+ return hash<std::string>()(s.raw());
+ }
+};
} // namespace __gnu_cxx
#endif