From 6f60253590427d382430ee1dd21bea1df22fb090 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Mon, 4 Apr 2016 14:57:43 -0500 Subject: [PATCH] Don't waste time looking for variables to (de)init in native classes --- src/dobjtype.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index fbc3ceb73..030016e46 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -3396,16 +3396,20 @@ DObject *PClass::CreateNew() const // // PClass :: InitializeSpecials // -// Initialize special fields of a newly-created instance (e.g. strings). +// Initialize special fields (e.g. strings) of a newly-created instance. // //========================================================================== void PClass::InitializeSpecials(void *addr) const { - if (ParentClass != NULL) + // Once we reach a native class, we can stop going up the family tree, + // since native classes handle initialization natively. + if (!bRuntimeClass) { - ParentClass->InitializeSpecials(addr); + return; } + assert(ParentClass != NULL); + ParentClass->InitializeSpecials(addr); for (auto tao : SpecialInits) { tao.first->InitializeValue((BYTE*)addr + tao.second, Defaults + tao.second); @@ -3416,19 +3420,27 @@ void PClass::InitializeSpecials(void *addr) const // // PClass :: DestroySpecials // +// Destroy special fields (e.g. strings) of an instance that is about to be +// deleted. +// //========================================================================== void PClass::DestroySpecials(void *addr) const { - if (ParentClass != NULL) + // Once we reach a native class, we can stop going up the family tree, + // since native classes handle deinitialization natively. + if (!bRuntimeClass) { - ParentClass->DestroySpecials(addr); + return; } + assert(ParentClass != NULL); + ParentClass->DestroySpecials(addr); for (auto tao : SpecialInits) { tao.first->DestroyValue((BYTE *)addr + tao.second); } } + //========================================================================== // // PClass :: Derive