Download

TMap<FString,~>::Find(const TCHAR*) problem

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!

Try Emplace?

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.

There is no FindByHash function in my unreal engine version 4.23

What about TMap<TCHAR*,~>?