storage/State: use std::hash() instead of boost::crc
Also eliminate the useless std::set.
This commit is contained in:
parent
a5d04be21f
commit
2e453ef58a
@ -40,9 +40,7 @@
|
|||||||
#pragma GCC diagnostic ignored "-Wcomma"
|
#pragma GCC diagnostic ignored "-Wcomma"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/crc.hpp>
|
#include <functional> // for std::hash()
|
||||||
|
|
||||||
#include <set>
|
|
||||||
|
|
||||||
#define MOUNT_STATE_BEGIN "mount_begin"
|
#define MOUNT_STATE_BEGIN "mount_begin"
|
||||||
#define MOUNT_STATE_END "mount_end"
|
#define MOUNT_STATE_END "mount_end"
|
||||||
@ -150,19 +148,16 @@ storage_state_get_hash(const Instance &instance) noexcept
|
|||||||
if (instance.storage == nullptr)
|
if (instance.storage == nullptr)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
std::set<std::string> mounts;
|
unsigned result = 0;
|
||||||
|
|
||||||
const auto visitor = [&mounts](const char *mount_uri, const Storage &storage) {
|
const std::hash<std::string_view> hash;
|
||||||
mounts.emplace(std::string(mount_uri) + ":" + storage.MapUTF8(""));
|
|
||||||
|
const auto visitor = [&result, &hash](const char *mount_uri, const Storage &storage) {
|
||||||
|
result = result * 33 + hash(mount_uri);
|
||||||
|
result = result * 33 + hash(storage.MapUTF8(""));
|
||||||
};
|
};
|
||||||
|
|
||||||
((CompositeStorage*)instance.storage)->VisitMounts(visitor);
|
((CompositeStorage*)instance.storage)->VisitMounts(visitor);
|
||||||
|
|
||||||
boost::crc_32_type result;
|
return result;
|
||||||
|
|
||||||
for (const auto& mount : mounts) {
|
|
||||||
result.process_bytes(mount.c_str(), mount.length());
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.checksum();
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user