MCPcopy Create free account
hub / github.com/bytedance/sonic-cpp / destroy

Method destroy

include/sonic/dom/dynamicnode.h:830–861  ·  view source on GitHub ↗

delete DNode's children or copied string

Source from the content-addressed store, hash-verified

828
829 // delete DNode's children or copied string
830 void destroy() {
831 if (!Allocator::kNeedFree) {
832 return;
833 }
834 switch (this->GetType()) {
835 case kObject: {
836 if (children()) {
837 DNode* node = getObjChildrenFirstUnsafe();
838 DNode* e = node + this->Size() * 2;
839 for (; node < e; node += 2) {
840 node->destroy();
841 (node + 1)->destroy();
842 }
843 static_cast<MetaNode*>(children())->~MetaNode();
844 }
845 Allocator::Free(children());
846 break;
847 }
848 case kArray: {
849 for (auto it = this->Begin(), e = this->End(); it != e; ++it) {
850 it->destroy();
851 }
852 Allocator::Free(children());
853 break;
854 }
855 case kStringFree:
856 Allocator::Free((void*)(this->sv.p));
857 break;
858 default:
859 break;
860 }
861 }
862
863 sonic_force_inline void rawAssign(DNode& rhs) {
864 this->data = rhs.data;

Callers 1

DNodeClass · 0.95

Calls 4

~MetaNodeMethod · 0.80
SizeMethod · 0.45
BeginMethod · 0.45
EndMethod · 0.45

Tested by

no test coverage detected