From 3de1c8332eddb52bc480b2aad23e0ee3f0308bb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20B=C4=9Bhan?= Date: Thu, 4 Jun 2015 16:25:21 +0200 Subject: [PATCH] better startup time when using --game regex ... especially when using generic --ignore-dlc-count='.*' previously, lgogdownloader would fetch game details for every game that indicated that it has DLCs. Which were all of them when used with --ignore-dlc-count - potentialy hundreds of http queries and cause of very slow startup with larger accounts. Regardless of what --game regex said. After the change, only initial list of all games is fetched, and then details for games that both the user is interested in AND they are suspected of having DLC. So it should help with startup time even when user doesn't use --ignore-dlc-count option. --- src/downloader.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/downloader.cpp b/src/downloader.cpp index 965de48..8a1fd89 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -2142,16 +2142,30 @@ std::vector Downloader::getGames() { int dlcCount = product["dlcCount"].asInt(); - bool bIgnoreDLCCount = false; - if (!config.sIgnoreDLCCountRegex.empty()) + bool bDownloadDLCInfo = (dlcCount != 0); + + if (!bDownloadDLCInfo && !config.sIgnoreDLCCountRegex.empty()) { boost::regex expression(config.sIgnoreDLCCountRegex); boost::match_results what; if (boost::regex_search(game.name, what, expression)) // Check if name matches the specified regex - bIgnoreDLCCount = true; + { + bDownloadDLCInfo = true; + } } - if (dlcCount != 0 || bIgnoreDLCCount) + if (bDownloadDLCInfo && !config.sGameRegex.empty()) + { + // don't download unnecessary info if user is only interested in a subset of his account + boost::regex expression(config.sGameRegex); + boost::match_results what; + if (!boost::regex_search(game.name, what, expression)) + { + bDownloadDLCInfo = false; + } + } + + if (bDownloadDLCInfo) { std::string gameinfo = this->getResponse("https://www.gog.com/account/gameDetails/" + game.id + ".json"); Json::Value info;