generate ep3 map list on demand
This commit is contained in:
+16
-19
@@ -802,10 +802,24 @@ Ep3DataIndex::Ep3DataIndex(const string& directory) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const string& Ep3DataIndex::get_compressed_card_definitions() const {
|
||||
if (this->compressed_card_definitions.empty()) {
|
||||
throw runtime_error("card definitions are not available");
|
||||
}
|
||||
return this->compressed_card_definitions;
|
||||
}
|
||||
|
||||
shared_ptr<const Ep3DataIndex::CardEntry> Ep3DataIndex::get_card_definition(
|
||||
uint32_t id) const {
|
||||
return this->card_definitions.at(id);
|
||||
}
|
||||
|
||||
const string& Ep3DataIndex::get_compressed_map_list() const {
|
||||
if (this->compressed_map_list.empty()) {
|
||||
// TODO: Write a version of prs_compress that takes iovecs (or something
|
||||
// similar) so we can eliminate all this string copying here. At least this
|
||||
// only happens once at load time...
|
||||
// similar) so we can eliminate all this string copying here.
|
||||
StringWriter entries_w;
|
||||
StringWriter strings_w;
|
||||
|
||||
@@ -856,23 +870,6 @@ Ep3DataIndex::Ep3DataIndex(const string& directory) {
|
||||
this->compressed_map_list = move(compressed_w.str());
|
||||
log(INFO, "Generated Episode 3 compressed map list (%zu -> %zu bytes)",
|
||||
w.size(), this->compressed_map_list.size());
|
||||
}
|
||||
|
||||
const string& Ep3DataIndex::get_compressed_card_definitions() const {
|
||||
if (this->compressed_card_definitions.empty()) {
|
||||
throw runtime_error("card definitions are not available");
|
||||
}
|
||||
return this->compressed_card_definitions;
|
||||
}
|
||||
|
||||
shared_ptr<const Ep3DataIndex::CardEntry> Ep3DataIndex::get_card_definition(
|
||||
uint32_t id) const {
|
||||
return this->card_definitions.at(id);
|
||||
}
|
||||
|
||||
const string& Ep3DataIndex::get_compressed_map_list() const {
|
||||
if (this->compressed_map_list.empty()) {
|
||||
throw runtime_error("map list is not available");
|
||||
}
|
||||
return this->compressed_map_list;
|
||||
}
|
||||
|
||||
+5
-1
@@ -335,6 +335,10 @@ private:
|
||||
std::string compressed_card_definitions;
|
||||
std::unordered_map<uint32_t, std::shared_ptr<CardEntry>> card_definitions;
|
||||
|
||||
std::string compressed_map_list;
|
||||
// The compressed map list is generated on demand from the maps map below.
|
||||
// It's marked mutable because the logical consistency of the Ep3DataIndex
|
||||
// object is not violated from the caller's perspective even if we don't
|
||||
// generate the compressed map list at load time.
|
||||
mutable std::string compressed_map_list;
|
||||
std::map<uint32_t, std::shared_ptr<MapEntry>> maps;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user