summaryrefslogtreecommitdiffhomepage
path: root/serialize
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-01-20 19:07:30 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-01-20 19:07:30 +0100
commit61234fbdb2cfe340016862d6458fad48d573bf2c (patch)
treea994c77eaf3cf3e506286f8a77d14f429fbfacf7 /serialize
parent670d15fbe177ed7018d8102ad5dc04c0c4a2d783 (diff)
w
Diffstat (limited to 'serialize')
-rw-r--r--serialize/savegame.cpp31
1 files changed, 9 insertions, 22 deletions
diff --git a/serialize/savegame.cpp b/serialize/savegame.cpp
index 765d0084..79ae7f28 100644
--- a/serialize/savegame.cpp
+++ b/serialize/savegame.cpp
@@ -45,21 +45,6 @@ constexpr inline auto object_magic = (uint16_t)0xb00b;
constexpr inline auto atlas_magic = (uint16_t)0xbeef;
constexpr inline auto null_atlas = (atlasid)-1;
-struct string_container
-{
- StringView str;
- bool operator==(const string_container&) const = default;
-
-#if 0
- friend void swap(string_container& a, string_container& b)
- {
- auto tmp = a.str;
- a.str = b.str;
- b.str = tmp;
- }
-#endif
-};
-
struct FILE_raii final
{
FILE_raii(FILE* s) noexcept : s{s} {}
@@ -187,18 +172,20 @@ struct visitor_
}
};
-struct writer final : visitor_<writer>
+struct string_hasher
{
- using string_hasher = decltype(
- [](const string_container& x) {
- return fnvhash_buf(x.str.data(), x.str.size());
- }
- );
+ inline size_t operator()(StringView s) const
+ {
+ return fnvhash_buf(s.data(), s.size());
+ }
+};
+struct writer final : visitor_<writer>
+{
const world& w;
std::vector<StringView> string_array{};
- tsl::robin_map<string_container, uint32_t, string_hasher> string_map{hash_initial_size};
+ tsl::robin_map<StringView, uint32_t, string_hasher> string_map{hash_initial_size};
std::vector<serialized_atlas> atlas_array{};
tsl::robin_map<const void*, uint32_t> atlas_map{hash_initial_size};