Optimize CSharp scripting runtime to use arena allocator per-assembly
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user