SungJin97
(SungJin97)
July 14, 2021, 3:04am
1
When pass const TCHAR* to TMap<FString,~>, implicitly FString temporary object is created.
Then literal string is copied to FString temporary object. this is slow.
I don’t want this. because it’s needless.
I think Hash value can be calculated with const TCAHR*(null-terminated).
But I can’t find way.
Please HELP!
SungJin97
(SungJin97)
July 14, 2021, 4:53pm
3
I’m wanna use TMap::Find function using literal string.
Currently, it makes temporary object when passing literal string to TMap::Find
You can use TMap::FindByHash if you want to pass in a hash or use MoveTempIfPossible(xxx) to try and use the && operator and avoid the object copy.
I think this could be faster than ::FindByHash(…) + GetTypeHash(…)
TMap< int64, FGeometry > HashMap;
{
const TCHAR* A = TEXT("Hello");
const TCHAR* B = TEXT("World");
int64 iA = TCString<TCHAR>::Atoi64(A);
int64 iB = TCString<TCHAR>::Atoi64(B);
HashMap.Add( iA , FGeometry{} );
HashMap.Add( iB, FGeometry{} );
FGeometry const & Geo = HashMap.FindChecked( iA );
}
DISCLAIMER : **Not tested.
SungJin97
(SungJin97)
July 15, 2021, 1:18am
6
ExtraLifeMatt:
FindByHash
There is no FindByHash function in my unreal engine version 4.23
What about TMap<TCHAR*,~>?