- added a cache and thread for loading of native language names to improve speed
This commit is contained in:
parent
6028ff30a6
commit
25fa436318
|
@ -564,14 +564,25 @@ string Lang::getLanguageFile(string uselanguage) {
|
|||
|
||||
string Lang::getNativeLanguageName(string uselanguage, string testLanguageFile) {
|
||||
string result = uselanguage;
|
||||
Properties stringsTest;
|
||||
stringsTest.load(testLanguageFile);
|
||||
|
||||
try {
|
||||
result = stringsTest.getString("NativeLanguageName");
|
||||
static map<string,string> cachedNativeLanguageNames;
|
||||
if(cachedNativeLanguageNames.find(testLanguageFile) != cachedNativeLanguageNames.end()) {
|
||||
result = cachedNativeLanguageNames[testLanguageFile];
|
||||
}
|
||||
//catch(const exception &ex) {
|
||||
catch(...) {
|
||||
else {
|
||||
Properties stringsTest;
|
||||
stringsTest.load(testLanguageFile);
|
||||
|
||||
try {
|
||||
result = stringsTest.getString("NativeLanguageName");
|
||||
cachedNativeLanguageNames[testLanguageFile] = result;
|
||||
|
||||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Caching native language name for [%s] = [%s]\n",testLanguageFile.c_str(),result.c_str());
|
||||
printf("Caching native language name for [%s] = [%s]\n",testLanguageFile.c_str(),result.c_str());
|
||||
}
|
||||
//catch(const exception &ex) {
|
||||
catch(...) {
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -111,6 +111,13 @@ static FileCRCPreCacheThread *preCacheThread = NULL;
|
|||
static string runtimeErrorMsg = "";
|
||||
#endif
|
||||
|
||||
class NavtiveLanguageNameListCacheGenerator : public SimpleTaskCallbackInterface {
|
||||
virtual void simpleTask(BaseThread *callingThread) {
|
||||
Lang &lang = Lang::getInstance();
|
||||
lang.getDiscoveredLanguageList(true);
|
||||
}
|
||||
};
|
||||
|
||||
void cleanupCRCThread() {
|
||||
if(preCacheThread != NULL) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
@ -4662,6 +4669,18 @@ int glestMain(int argc, char** argv) {
|
|||
preCacheThread->start();
|
||||
}
|
||||
|
||||
std::auto_ptr<NavtiveLanguageNameListCacheGenerator> lngCacheGen;
|
||||
std::auto_ptr<SimpleTaskThread> languageCacheGen;
|
||||
|
||||
bool startNativeLanguageNamesPrecacheThread = config.getBool("PreCacheNativeLanguageNamesThread","true");
|
||||
if(startNativeLanguageNamesPrecacheThread == true &&
|
||||
GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
||||
lngCacheGen.reset(new NavtiveLanguageNameListCacheGenerator());
|
||||
languageCacheGen.reset(new SimpleTaskThread(lngCacheGen.get(),1));
|
||||
|
||||
languageCacheGen->start();
|
||||
}
|
||||
|
||||
// test
|
||||
//Shared::Platform::MessageBox(NULL,"Mark's test.","Test",0);
|
||||
//throw megaglest_runtime_error("test!");
|
||||
|
|
Loading…
Reference in New Issue