mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
Remove unnecessary delete statements
If a value is null, the C++ delete statement will do nothing, so there is bo need to explicitly check if the value is null.
This commit is contained in:
parent
43187e233a
commit
5f3329e121
12 changed files with 22 additions and 41 deletions
|
@ -925,11 +925,8 @@ void BfContext::RebuildType(BfType* type, bool deleteOnDemandTypes, bool rebuild
|
|||
}
|
||||
else
|
||||
{
|
||||
if (typeInst->mHotTypeData != NULL)
|
||||
{
|
||||
delete typeInst->mHotTypeData;
|
||||
typeInst->mHotTypeData = NULL;
|
||||
}
|
||||
delete typeInst->mHotTypeData;
|
||||
typeInst->mHotTypeData = NULL;
|
||||
}
|
||||
|
||||
auto typeDef = typeInst->mTypeDef;
|
||||
|
@ -1009,12 +1006,9 @@ void BfContext::RebuildType(BfType* type, bool deleteOnDemandTypes, bool rebuild
|
|||
typeInst->mTypeWarned = false;
|
||||
typeInst->mIsSplattable = false;
|
||||
typeInst->mHasPackingHoles = false;
|
||||
typeInst->mWantsGCMarking = false;
|
||||
if (typeInst->mTypeInfoEx != NULL)
|
||||
{
|
||||
delete typeInst->mTypeInfoEx;
|
||||
typeInst->mTypeInfoEx = NULL;
|
||||
}
|
||||
typeInst->mWantsGCMarking = false;
|
||||
delete typeInst->mTypeInfoEx;
|
||||
typeInst->mTypeInfoEx = NULL;
|
||||
|
||||
if (typeInst->IsGenericTypeInstance())
|
||||
{
|
||||
|
|
|
@ -1583,8 +1583,7 @@ void BfDefBuilder::Visit(BfTypeDeclaration* typeDeclaration)
|
|||
|
||||
if (prevRevisionTypeDef->mDefState == BfTypeDef::DefState_AwaitingNewVersion)
|
||||
{
|
||||
if (prevRevisionTypeDef->mNextRevision != NULL)
|
||||
delete prevRevisionTypeDef->mNextRevision;
|
||||
delete prevRevisionTypeDef->mNextRevision;
|
||||
prevRevisionTypeDef->mNextRevision = mCurTypeDef;
|
||||
BF_ASSERT(mCurTypeDef->mSystem != NULL);
|
||||
mCurActualTypeDef = prevRevisionTypeDef;
|
||||
|
|
|
@ -6028,8 +6028,8 @@ BfType* BfModule::ResolveGenericType(BfType* unspecializedType, BfTypeVector* ty
|
|||
delegateType = dlgType;
|
||||
}
|
||||
|
||||
if (delegateType->mTypeDef != NULL)
|
||||
delete delegateType->mTypeDef;
|
||||
delete delegateType->mTypeDef;
|
||||
delegateType->mTypeDef = NULL;
|
||||
BfDelegateInfo* delegateInfo = delegateType->GetDelegateInfo();
|
||||
delegateInfo->mParams.Clear();
|
||||
|
||||
|
|
|
@ -3403,8 +3403,7 @@ BF_EXPORT void BF_CALLTYPE BfParser_SetSource(BfParser* bfParser, const char* da
|
|||
|
||||
BF_EXPORT void BF_CALLTYPE BfParser_SetCharIdData(BfParser* bfParser, uint8* data, int length)
|
||||
{
|
||||
if (bfParser->mParserData->mCharIdData != NULL)
|
||||
delete bfParser->mParserData->mCharIdData;
|
||||
delete bfParser->mParserData->mCharIdData;
|
||||
bfParser->mParserData->mCharIdData = new uint8[length];
|
||||
memcpy(bfParser->mParserData->mCharIdData, data, length);
|
||||
}
|
||||
|
|
|
@ -1878,8 +1878,7 @@ BfGenericTypeInfo::~BfGenericTypeInfo()
|
|||
{
|
||||
for (auto genericParamInstance : mGenericParams)
|
||||
genericParamInstance->Release();
|
||||
if (mGenericExtensionInfo != NULL)
|
||||
delete mGenericExtensionInfo;
|
||||
delete mGenericExtensionInfo;
|
||||
}
|
||||
|
||||
BfGenericTypeInfo::GenericParamsVector* BfTypeInstance::GetGenericParamsVector(BfTypeDef* declaringTypeDef)
|
||||
|
|
|
@ -38,8 +38,7 @@ BfSource::~BfSource()
|
|||
{
|
||||
int sourceCount = gSourceCount--;
|
||||
|
||||
if (mSourceData != NULL)
|
||||
delete mSourceData;
|
||||
delete mSourceData;
|
||||
|
||||
if (mSrcAllocSize >= 0)
|
||||
delete mSrc;
|
||||
|
|
|
@ -694,8 +694,7 @@ void BfTypeDef::PopulateMemberSets()
|
|||
BfTypeDef::~BfTypeDef()
|
||||
{
|
||||
BfLogSysM("BfTypeDef::~BfTypeDef %08X\n", this);
|
||||
if (mNextRevision != NULL)
|
||||
delete mNextRevision;
|
||||
delete mNextRevision;
|
||||
FreeMembers();
|
||||
|
||||
if (mSource != NULL)
|
||||
|
@ -3139,8 +3138,7 @@ void BfSystem::RemoveDeletedParsers()
|
|||
}
|
||||
|
||||
BfLogSys(this, "Removing Queued Parser: %p\n", bfParser);
|
||||
if (bfParser != NULL)
|
||||
delete bfParser;
|
||||
delete bfParser;
|
||||
CheckLockYield();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue