coords/units hashing refactoring

This commit is contained in:
Maxime Coste 2015-03-11 13:59:25 +00:00
parent 023c8afb73
commit a0e8e4265a
3 changed files with 8 additions and 18 deletions

View File

@ -84,6 +84,11 @@ struct LineAndColumn
{ {
return line != other.line or column != other.column; return line != other.line or column != other.column;
} }
friend size_t hash_value(const EffectiveType& val)
{
return hash_values(val.line, val.column);
}
}; };
struct ByteCoord : LineAndColumn<ByteCoord, LineCount, ByteCount> struct ByteCoord : LineAndColumn<ByteCoord, LineCount, ByteCount>
@ -93,11 +98,6 @@ struct ByteCoord : LineAndColumn<ByteCoord, LineCount, ByteCount>
: LineAndColumn(line, column) {} : LineAndColumn(line, column) {}
}; };
inline size_t hash_value(const ByteCoord& val)
{
return hash_values(val.line, val.column);
}
struct CharCoord : LineAndColumn<CharCoord, LineCount, CharCount> struct CharCoord : LineAndColumn<CharCoord, LineCount, CharCount>
{ {
[[gnu::always_inline]] [[gnu::always_inline]]
@ -105,11 +105,6 @@ struct CharCoord : LineAndColumn<CharCoord, LineCount, CharCount>
: LineAndColumn(line, column) {} : LineAndColumn(line, column) {}
}; };
inline size_t hash_value(const CharCoord& val)
{
return hash_values(val.line, val.column);
}
struct ByteCoordAndTarget : ByteCoord struct ByteCoordAndTarget : ByteCoord
{ {
[[gnu::always_inline]] [[gnu::always_inline]]

View File

@ -111,6 +111,9 @@ public:
explicit constexpr operator ValueType() const { return m_value; } explicit constexpr operator ValueType() const { return m_value; }
[[gnu::always_inline]] [[gnu::always_inline]]
explicit constexpr operator bool() const { return m_value; } explicit constexpr operator bool() const { return m_value; }
friend size_t hash_value(RealType val) { return hash_value(val.m_value); }
private: private:
ValueType m_value; ValueType m_value;
}; };
@ -121,8 +124,6 @@ struct LineCount : public StronglyTypedNumber<LineCount, int>
constexpr LineCount(int value = 0) : StronglyTypedNumber<LineCount>(value) {} constexpr LineCount(int value = 0) : StronglyTypedNumber<LineCount>(value) {}
}; };
inline size_t hash_value(LineCount val) { return hash_value((int)val); }
[[gnu::always_inline]] [[gnu::always_inline]]
inline constexpr LineCount operator"" _line(unsigned long long int value) inline constexpr LineCount operator"" _line(unsigned long long int value)
{ {
@ -135,8 +136,6 @@ struct ByteCount : public StronglyTypedNumber<ByteCount, int>
constexpr ByteCount(int value = 0) : StronglyTypedNumber<ByteCount>(value) {} constexpr ByteCount(int value = 0) : StronglyTypedNumber<ByteCount>(value) {}
}; };
inline size_t hash_value(ByteCount val) { return hash_value((int)val); }
[[gnu::always_inline]] [[gnu::always_inline]]
inline constexpr ByteCount operator"" _byte(unsigned long long int value) inline constexpr ByteCount operator"" _byte(unsigned long long int value)
{ {
@ -155,8 +154,6 @@ inline constexpr CharCount operator"" _char(unsigned long long int value)
return CharCount(value); return CharCount(value);
} }
inline size_t hash_value(CharCount val) { return hash_value((int)val); }
} }
#endif // units_hh_INCLUDED #endif // units_hh_INCLUDED

View File

@ -76,8 +76,6 @@ struct ValueId : public StronglyTypedNumber<ValueId, int>
} }
}; };
inline size_t hash_value(ValueId val) { return hash_value((int)val); }
using ValueMap = UnorderedMap<ValueId, Value, MemoryDomain::Values>; using ValueMap = UnorderedMap<ValueId, Value, MemoryDomain::Values>;
} }