Optimize CSharp scripting runtime to use arena allocator per-assembly

This commit is contained in:
Wojtek Figat
2025-05-25 02:04:16 +02:00
parent f9cb4ddae2
commit 410ec0465c
15 changed files with 126 additions and 78 deletions

View File

@@ -44,9 +44,19 @@ public:
return ptr;
}
// Invokes destructor on values in an array and clears it.
template<typename Value, typename Allocator>
static void ClearDelete(Array<Value, Allocator>& collection)
{
Value* ptr = collection.Get();
for (int32 i = 0; i < collection.Count(); i++)
Memory::DestructItem(ptr[i]);
collection.Clear();
}
// Invokes destructor on values in a dictionary and clears it.
template<typename Key, typename Value, typename Allocator>
void ClearDelete(Dictionary<Key, Value, Allocator>& collection)
static void ClearDelete(Dictionary<Key, Value, Allocator>& collection)
{
for (auto it = collection.Begin(); it.IsNotEnd(); ++it)
Memory::DestructItem(it->Value);

View File

@@ -118,7 +118,7 @@ VariantType::VariantType(Types type, const MClass* klass)
#if USE_CSHARP
if (klass)
{
const StringAnsi& typeName = klass->GetFullName();
const StringAnsiView typeName = klass->GetFullName();
const int32 length = typeName.Length();
TypeName = static_cast<char*>(Allocator::Allocate(length + 1));
Platform::MemoryCopy(TypeName, typeName.Get(), length);