speeding up fastscript ...
I have found a way to get significant speedups when calling external procedures and functions!
Since FastScript is using CreateVarArray to pass parameters to CallMethod, I've changed VarArray to simple array of variant! Altough I needed to change delcarations all over ... I was amazed ... 500% speedup!
I still didn't discover any incompatibilites. It works well for me ...
So here's the code :
change "var Params: variant" in TfsCallMethodEvent to "var Params: array of variant"
//
function TfsMethodHelper.GetValue: Variant;
var
v: array of Variant;
i: Integer;
s: String;
Instance: TObject;
begin
if Assigned(FOnCall) then
begin
SetLength(v, Count);
for i := 0 to Count - 1 do
v := Params.Value;
s := Name;
if FIndexMethod then
s := s + '.Get';
Instance := nil;
if ParentValue <> Null then
Instance := TObject(Integer(ParentValue));
Result := FOnCall(Self.FProgram, Instance, FClassRef, {Ansi}UpperCase(s), v);
for i := 0 to Count - 1 do
if Params.IsVarParam then
Params.Value := v;
SetLength(v, 0);
end
else
Result := 0;
end;
Since FastScript is using CreateVarArray to pass parameters to CallMethod, I've changed VarArray to simple array of variant! Altough I needed to change delcarations all over ... I was amazed ... 500% speedup!
I still didn't discover any incompatibilites. It works well for me ...
So here's the code :
change "var Params: variant" in TfsCallMethodEvent to "var Params: array of variant"
//
function TfsMethodHelper.GetValue: Variant;
var
v: array of Variant;
i: Integer;
s: String;
Instance: TObject;
begin
if Assigned(FOnCall) then
begin
SetLength(v, Count);
for i := 0 to Count - 1 do
v := Params.Value;
s := Name;
if FIndexMethod then
s := s + '.Get';
Instance := nil;
if ParentValue <> Null then
Instance := TObject(Integer(ParentValue));
Result := FOnCall(Self.FProgram, Instance, FClassRef, {Ansi}UpperCase(s), v);
for i := 0 to Count - 1 do
if Params.IsVarParam then
Params.Value := v;
SetLength(v, 0);
end
else
Result := 0;
end;