Issue found with PVS-Studio:

Many instances where we would create a object via a new call, and then check that it was non-null.

This is redundant, as if we ever were in a situation where new failed, we'd be crashing left and right already, so the additional check is wasted processing.
This commit is contained in:
Areloch 2015-07-21 23:22:21 -05:00
parent db532c0e1a
commit 527c3790d6
15 changed files with 164 additions and 262 deletions

View file

@ -250,18 +250,16 @@ S32 LangTable::addLanguage(LangFile *lang, const UTF8 *name /* = NULL */)
S32 LangTable::addLanguage(const UTF8 *filename, const UTF8 *name /* = NULL */)
{
LangFile * lang = new LangFile(name);
if(lang != NULL)
if(Torque::FS::IsFile(filename))
{
if(Torque::FS::IsFile(filename))
{
lang->setLangFile(filename);
lang->setLangFile(filename);
S32 ret = addLanguage(lang);
if(ret >= 0)
return ret;
}
delete lang;
S32 ret = addLanguage(lang);
if(ret >= 0)
return ret;
}
delete lang;
return -1;
}