- changed VMValue to handle strings by reference.

This makes VMValue a real POD type with no hacky overloads and eliminates a lot of destructor code in all places that call a VM function. Due to the way this had to be handled, none of these destructors could be skipped because any value could have been a string.
This required some minor changes in functions that passed a temporary FString into the VM to ensure that the temporary object lives long enough to be handled. The code generator had already been changed to deal with this in a previous commit.
This is easily offset by the code savings and reduced maintenance needs elsewhere.
This commit is contained in:
Christoph Oelckers 2017-03-22 01:44:56 +01:00
commit 4417afd548
9 changed files with 55 additions and 93 deletions

View file

@ -386,12 +386,15 @@ static void ParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc)
}
auto TypeCVar = NewPointer(NewNativeStruct("CVar", nullptr));
// Note that this array may not be reallocated so its initial size must be the maximum possible elements.
TArray<FString> strings(args.Size());
for (unsigned i = start; i < args.Size(); i++)
{
sc.MustGetString();
if (args[i] == TypeString)
{
params.Push(FString(sc.String));
strings.Push(sc.String);
params.Push(&strings.Last());
}
else if (args[i] == TypeName)
{
@ -751,12 +754,16 @@ static void ParseOptionMenuBody(FScanner &sc, DOptionMenuDescriptor *desc)
params.Push(0);
auto TypeCVar = NewPointer(NewNativeStruct("CVar", nullptr));
// Note that this array may not be reallocated so its initial size must be the maximum possible elements.
TArray<FString> strings(args.Size());
for (unsigned i = 1; i < args.Size(); i++)
{
sc.MustGetString();
if (args[i] == TypeString)
{
params.Push(FString(sc.String));
strings.Push(sc.String);
params.Push(&strings.Last());
}
else if (args[i] == TypeName)
{