Permalink
Browse files

Merge pull request #11370 from unknownbrackets/tex-replace

Replacement: Cut down on parsing for large inis
  • Loading branch information...
hrydgard committed Sep 9, 2018
2 parents 7a5ec71 + 1b4f1d7 commit 47cccc0ff00cc0db925988e57e9bd9308a24b0da
Showing with 10 additions and 15 deletions.
  1. +10 −15 Core/TextureReplacer.cpp
View
@@ -112,29 +112,24 @@ bool TextureReplacer::LoadIni() {
ERROR_LOG(G3D, "Unsupported texture replacement version %d, trying anyway", version);
}
std::vector<std::string> hashNames;
if (ini.GetKeys("hashes", hashNames)) {
auto hashes = ini.GetOrCreateSection("hashes");
if (ini.HasSection("hashes")) {
auto hashes = ini.GetOrCreateSection("hashes")->ToMap();
// Format: hashname = filename.png
for (std::string hashName : hashNames) {
for (const auto &item : hashes) {
ReplacementAliasKey key(0, 0, 0);
if (sscanf(hashName.c_str(), "%16llx%8x_%d", &key.cachekey, &key.hash, &key.level) >= 1) {
hashes->Get(hashName.c_str(), &aliases_[key], "");
if (sscanf(item.first.c_str(), "%16llx%8x_%d", &key.cachekey, &key.hash, &key.level) >= 1) {
aliases_[key] = item.second;
} else {
ERROR_LOG(G3D, "Unsupported syntax under [hashes]: %s", hashName.c_str());
ERROR_LOG(G3D, "Unsupported syntax under [hashes]: %s", item.first.c_str());
}
}
}
std::vector<std::string> hashrangeKeys;
if (ini.GetKeys("hashranges", hashrangeKeys)) {
auto hashranges = ini.GetOrCreateSection("hashranges");
if (ini.HasSection("hashranges")) {
auto hashranges = ini.GetOrCreateSection("hashranges")->ToMap();
// Format: addr,w,h = newW,newH
for (const std::string &key : hashrangeKeys) {
std::string value;
if (hashranges->Get(key.c_str(), &value, "")) {
ParseHashRange(key, value);
}
for (const auto &item : hashranges) {
ParseHashRange(item.first, item.second);
}
}
}

1 comment on commit 47cccc0

@AkiraJkr

This comment has been minimized.

Show comment
Hide comment
@AkiraJkr

AkiraJkr Sep 9, 2018

Can confirm that this commit has improved performance of loading the texture.inis.

Kingdom Hearts before took 4/7 seconds to load, depending of your hardware. Now it's either 1 second or much less. You barely notice texture replacement is affecting loading times.
Same goes for Fate/Extra.

Also, there's no more hangs when unpausing after writing on config file. It loads immediately, almost as if textures.ini was NEVER being loaded. Issue fixed.

AkiraJkr commented on 47cccc0 Sep 9, 2018

Can confirm that this commit has improved performance of loading the texture.inis.

Kingdom Hearts before took 4/7 seconds to load, depending of your hardware. Now it's either 1 second or much less. You barely notice texture replacement is affecting loading times.
Same goes for Fate/Extra.

Also, there's no more hangs when unpausing after writing on config file. It loads immediately, almost as if textures.ini was NEVER being loaded. Issue fixed.

Please sign in to comment.