MCPcopy Create free account
hub / github.com/ZDoom/Raze / put

Method put

libraries/asmjit/asmjit/base/constpool.cpp:78–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78void ConstPool::Tree::put(ConstPool::Node* newNode) noexcept {
79 size_t dataSize = _dataSize;
80 _length++;
81
82 if (!_root) {
83 _root = newNode;
84 return;
85 }
86
87 ConstPool::Node* node = _root;
88 ConstPool::Node* stack[kHeightLimit];
89
90 unsigned int top = 0;
91 unsigned int dir;
92
93 // Find a spot and save the stack.
94 for (;;) {
95 stack[top++] = node;
96 dir = ::memcmp(node->getData(), newNode->getData(), dataSize) < 0;
97
98 ConstPool::Node* link = node->_link[dir];
99 if (!link) break;
100
101 node = link;
102 }
103
104 // Link and rebalance.
105 node->_link[dir] = newNode;
106
107 while (top > 0) {
108 // Which child?
109 node = stack[--top];
110
111 if (top != 0) {
112 dir = stack[top - 1]->_link[1] == node;
113 }
114
115 node = ConstPoolTree_skewNode(node);
116 node = ConstPoolTree_splitNode(node);
117
118 // Fix the parent.
119 if (top != 0)
120 stack[top - 1]->_link[dir] = node;
121 else
122 _root = node;
123 }
124}
125
126// ============================================================================
127// [asmjit::ConstPool - Construction / Destruction]

Callers 3

FinishRowFunction · 0.45
newNamedLabelIdMethod · 0.45
addMethod · 0.45

Calls 3

ConstPoolTree_skewNodeFunction · 0.85
ConstPoolTree_splitNodeFunction · 0.85
getDataMethod · 0.45

Tested by

no test coverage detected