Does anyone know the logic behind Instance Number assignment in FName? Why it is 1 or 2 or 3, what is the relation to the the string name itself ?
The number portion is the instance of that string (index into a hash bucket list). Where as the other values are indices into a hash table based on the CRC of the string you provide. You can read through NameTypes.h / UnrealNames.cpp if you want to follow the code.
I understand they are instance numbers. As you may have noticed I even called them so because, well, that is how they are called. I’m asking about logic behind them. Why dome FName have instance up to 100 or 500, for example? How are they counted, inside what system/space?
Look at UnrealNames.h and NameTypes.h, the code is right there. You can even open up UnrealNames.inl and see a bunch of the hard coded FNames (0 - 600, with some gaps here and there). It’s all just indices into a flat list. Nothing crazy.
Pretty sure they are hardcoded because they were pre-generated but I’m asking about FName instance numbers in the project resources like DataTables. What makes specific FName in my DataTable has instance number 2 or 564? Are they counted across whole project? Or some subsystem/subspace? Or just this specific asset (unlikely since example DataTable does not have so much usage of that FName)
FName is a combination of a string and a number.
If you have a bunch of objects named “MyObject_1”, “MyObject_2”, “MyObject_3” etc. the “MyObject” part is going to be stored only once. Each name will refer the same string part and will have a unique number part. This is a memory-saving technique which works good given that standard name generation scheme in UE4 uses class name as a string part for an object name and increments the number part.
Everything is clear now, thank you.