MCPcopy Create free account
hub / github.com/defold/defold / Enable

Method Enable

engine/dlib/src/dlib/hash.cpp:80–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78 }
79
80 void Enable(bool enable)
81 {
82 if(m_Enabled == enable)
83 return;
84 DM_MUTEX_SCOPED_LOCK(m_Mutex);
85 m_Enabled = enable;
86
87 if(enable)
88 {
89 if (m_HashTable32Entries.Full())
90 IncreaseTableCapacity(&m_HashTable32Entries, m_HashTableCapacityIncrement);
91 if (m_HashTable64Entries.Full())
92 IncreaseTableCapacity(&m_HashTable64Entries, m_HashTableCapacityIncrement);
93 m_HashTable32Entries.Clear();
94 m_HashTable64Entries.Clear();
95 m_HashStates.SetCapacity(m_HashStatesCapacity);
96 m_HashStates.SetSize(m_HashStatesCapacity);
97 m_HashStatesSlots.SetCapacity(m_HashStatesCapacity);
98 m_HashStatesSlots.Clear();
99 uint32_t invalid_slot = m_HashStatesSlots.Pop();
100 assert(invalid_slot == 0); // we rely on first index to be 0 in the index pool implementation. 0 implies invalid/unused slot.
101 }
102 else
103 {
104 m_HashTable32Entries.Iterate(FreeEntryCallback, (void*) 0);
105 m_HashTable32Entries.Clear();
106 m_HashTable64Entries.Iterate(FreeEntryCallback, (void*) 0);
107 m_HashTable64Entries.Clear();
108 if(m_HashStatesSlots.Size() != 0)
109 {
110 m_HashStatesSlots.Push(0);
111 m_HashStatesSlots.IterateRemaining(FreeStateCallback, (void*) &m_HashStates);
112 for(uint32_t i = 0; i < m_HashStates.Size(); ++i)
113 {
114 if(m_HashStates[i].m_Value)
115 {
116 free(m_HashStates[i].m_Value);
117 }
118 }
119 m_HashStatesSlots.Clear();
120 }
121 }
122 }
123
124 inline uint32_t AllocReverseHashStatesSlot()
125 {

Callers 1

dmHashEnableReverseHashFunction · 0.80

Calls 12

IncreaseTableCapacityFunction · 0.85
freeFunction · 0.85
IterateMethod · 0.80
IterateRemainingMethod · 0.80
assertFunction · 0.50
FullMethod · 0.45
ClearMethod · 0.45
SetCapacityMethod · 0.45
SetSizeMethod · 0.45
PopMethod · 0.45
SizeMethod · 0.45
PushMethod · 0.45

Tested by

no test coverage detected