@@ -15,42 +15,31 @@
1515#ifndef PS_MapKey_HH
1616#define PS_MapKey_HH
1717
18+#include <utility>
1819#include "hash.hh"
1920
2021namespace PureScript {
2122
22− struct map_key_t {
23−
24− const uint32_t hash;
25−
26− explicit constexpr map_key_t(const uint32_t hash) : hash(hash) {}
23+ class map_key_t : public std::pair<uint32_t, std::string> {
24+ public:
25+ using std::pair<uint32_t, std::string>::pair;
2726
2827 class hasher {
2928 public:
30− constexpr auto operator() (const map_key_t key) const -> size_t {
31− return key.hash;
29+ auto operator() (const map_key_t& key) const -> size_t {
30+ return key.first;
3231 }
3332 };
3433
3534 class equal {
3635 public:
37− constexpr auto operator() (const map_key_t key1, const map_key_t key2) const -> bool {
38− return key1.hash == key2.hash;
36+ auto operator() (const map_key_t& key1, const map_key_t& key2) const -> bool {
37+ return key1.second == key2.second;
3938 }
4039 };
4140 };
4241
43− // Compile-time map keys (from strings)
44− //
45− template <uint32_t H>
46− struct _compile_time_key_ {
47− static constexpr map_key_t value = map_key_t(H);
48− };
49−
50− template <uint32_t H>
51− constexpr map_key_t _compile_time_key_<H>::value;
52−
53− #define KEY(s) _compile_time_key_<djb2(s)>::value
42+ #define KEY(s) map_key_t(HASH(s), s)
5443
5544} // namespace PureScript
5645