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

Method buildHashTable

Engine/source/console/consoleInternal.cpp:1040–1088  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1038}
1039
1040void Namespace::buildHashTable()
1041{
1042 if(mHashSequence == mCacheSequence)
1043 return;
1044
1045 if(!mEntryList && mParent)
1046 {
1047 mParent->buildHashTable();
1048 mHashTable = mParent->mHashTable;
1049 mHashSize = mParent->mHashSize;
1050 mHashSequence = mCacheSequence;
1051 return;
1052 }
1053
1054 U32 entryCount = 0;
1055 Namespace * ns;
1056 for(ns = this; ns; ns = ns->mParent)
1057 for(Entry *walk = ns->mEntryList; walk; walk = walk->mNext)
1058 if(lookupRecursive(walk->mFunctionName) == walk)
1059 entryCount++;
1060
1061 mHashSize = entryCount + (entryCount >> 1) + 1;
1062
1063 if(!(mHashSize & 1))
1064 mHashSize++;
1065
1066 mHashTable = (Entry **) mCacheAllocator.alloc(sizeof(Entry *) * mHashSize);
1067 for(U32 i = 0; i < mHashSize; i++)
1068 mHashTable[i] = NULL;
1069
1070 for(ns = this; ns; ns = ns->mParent)
1071 {
1072 for(Entry *walk = ns->mEntryList; walk; walk = walk->mNext)
1073 {
1074 U32 index = HashPointer(walk->mFunctionName) % mHashSize;
1075 while(mHashTable[index] && mHashTable[index]->mFunctionName != walk->mFunctionName)
1076 {
1077 index++;
1078 if(index >= mHashSize)
1079 index = 0;
1080 }
1081
1082 if(!mHashTable[index])
1083 mHashTable[index] = walk;
1084 }
1085 }
1086
1087 mHashSequence = mCacheSequence;
1088}
1089
1090void Namespace::getUniqueEntryLists( Namespace *other, VectorPtr<Entry *> *outThisList, VectorPtr<Entry *> *outOtherList )
1091{

Callers

nothing calls this directly

Calls 2

HashPointerFunction · 0.85
allocMethod · 0.45

Tested by

no test coverage detected