delete DNode's children or copied string
| 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; |