From d6d2a37d03ec83a7699c1313a50bd12a0563bab3 Mon Sep 17 00:00:00 2001 From: fteppe Date: Sun, 2 Oct 2022 23:20:32 +0200 Subject: [PATCH] some clean and better comments --- components/esm/refid.cpp | 13 ------------- components/esm/refid.hpp | 33 +++++++++++---------------------- 2 files changed, 11 insertions(+), 35 deletions(-) diff --git a/components/esm/refid.cpp b/components/esm/refid.cpp index 99b80f465f..6ab1b8cfc5 100644 --- a/components/esm/refid.cpp +++ b/components/esm/refid.cpp @@ -27,16 +27,3 @@ ESM::RefId ESM::RefId::stringRefId(const std::string_view & id) const ESM::RefId ESM::RefId::sEmpty = ESM::RefId::stringRefId(""); -//template<> -//std::size_t std::hash::operator()(const ESM::RefId& k) const -//{ -// using std::size_t; -// using std::hash; -// using std::string; -// -// // Compute individual hash values for first, -// // second and third and combine them using XOR -// // and bit shifting: -// -// return hash()(k.getRefIdString()); -//} diff --git a/components/esm/refid.hpp b/components/esm/refid.hpp index 116ff17574..20d7707b79 100644 --- a/components/esm/refid.hpp +++ b/components/esm/refid.hpp @@ -1,8 +1,8 @@ #ifndef OPENMW_COMPONENTS_ESM_REFID_HPP #define OPENMW_COMPONENTS_ESM_REFID_HPP -#include -#include #include +#include +#include namespace ESM { @@ -14,45 +14,34 @@ namespace ESM void swap(RefId& rhs) { mId.swap(rhs.mId); } bool operator==(const RefId& rhs) const { return mId == rhs.mId; } void operator=(const RefId& rhs) { mId = rhs.mId; } - bool operator <(const RefId& rhs) const - { - return mId < rhs.mId; - } - bool operator >(const RefId& rhs) const - { - return mId > rhs.mId; - } + bool operator<(const RefId& rhs) const { return mId < rhs.mId; } + bool operator>(const RefId& rhs) const { return mId > rhs.mId; } + static bool ciEqual(const RefId& left, const RefId& right); friend std::ostream& operator<<(std::ostream& os, const RefId& dt); - static RefId stringRefId( - const std::string_view& id); // This makes it very visible the places where I had to convert from string to Refid + static RefId stringRefId(const std::string_view& id); //The + std::string& getRefIdString() { return mId; } + const std::string& getRefIdString() const { return mId; } - std::string& getRefIdString() { return mId; } // Same thing - const std::string& getRefIdString() const { return mId; } // Same thing - - static bool ciEqual(const RefId& left, const RefId& right); private: std::string mId; }; } -namespace std { +namespace std +{ template <> struct hash { std::size_t operator()(const ESM::RefId& k) const { - using std::size_t; using std::hash; + using std::size_t; using std::string; - // Compute individual hash values for first, - // second and third and combine them using XOR - // and bit shifting: - return hash()(k.getRefIdString()); } };