MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / buildHashTable

Method buildHashTable

Engine/source/console/consoleInternal.cpp:1022–1070  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1020}
1021
1022void Namespace::buildHashTable()
1023{
1024 if (mHashSequence == mCacheSequence)
1025 return;
1026
1027 if (!mEntryList && mParent)
1028 {
1029 mParent->buildHashTable();
1030 mHashTable = mParent->mHashTable;
1031 mHashSize = mParent->mHashSize;
1032 mHashSequence = mCacheSequence;
1033 return;
1034 }
1035
1036 U32 entryCount = 0;
1037 Namespace * ns;
1038 for (ns = this; ns; ns = ns->mParent)
1039 for (Entry *walk = ns->mEntryList; walk; walk = walk->mNext)
1040 if (lookupRecursive(walk->mFunctionName) == walk)
1041 entryCount++;
1042
1043 mHashSize = entryCount + (entryCount >> 1) + 1;
1044
1045 if (!(mHashSize & 1))
1046 mHashSize++;
1047
1048 mHashTable = (Entry **)mCacheAllocator.alloc(sizeof(Entry *) * mHashSize);
1049 for (U32 i = 0; i < mHashSize; i++)
1050 mHashTable[i] = NULL;
1051
1052 for (ns = this; ns; ns = ns->mParent)
1053 {
1054 for (Entry *walk = ns->mEntryList; walk; walk = walk->mNext)
1055 {
1056 U32 index = HashPointer(walk->mFunctionName) % mHashSize;
1057 while (mHashTable[index] && mHashTable[index]->mFunctionName != walk->mFunctionName)
1058 {
1059 index++;
1060 if (index >= mHashSize)
1061 index = 0;
1062 }
1063
1064 if (!mHashTable[index])
1065 mHashTable[index] = walk;
1066 }
1067 }
1068
1069 mHashSequence = mCacheSequence;
1070}
1071
1072void Namespace::getUniqueEntryLists(Namespace *other, VectorPtr<Entry *> *outThisList, VectorPtr<Entry *> *outOtherList)
1073{

Callers

nothing calls this directly

Calls 2

HashPointerFunction · 0.85
allocMethod · 0.45

Tested by

no test coverage detected