Sir R. M8gic1an
2010-12-05 17:31:48
I found an inefficiency and I decided to post it here for learning purposes:
Why are you assigning an array in a loop?
It's looping the assignment of a variable that is not changing, every time it loops, accessing the memory every time it loops, etc.
@Simba: Does simba have short circuit evaluation? Is PascalScript the limitation on it?
And yeh.. I'm currently looking for a bug in MSI :p (pickaxe drop)
~RM
function MSI_AutoInvFull(Func: function(a: TIntegerArray; var b: Boolean): Boolean): Boolean;
var
t, waitTime, tTime: Integer;
tObjects, newObjects: TIntegerArray;
forceFail: Boolean;
begin
t := (GetSystemTime + (5 * 60000));
repeat
while (not InvFull) and (LoggedIn) do
with MSI_Players[CurrentPlayer] do
begin
case (MSI_Scripts[Scripts[CurrentScript].Name].SkillConst) of
SKILL_WOODCUTTING: tObjects := Scripts[CurrentScript].Trees;
SKILL_MINING: tObjects := Scripts[CurrentScript].Rocks;
SKILL_FISHING: tObjects := Scripts[CurrentScript].FishSpots;
end;
Why are you assigning an array in a loop?
It's looping the assignment of a variable that is not changing, every time it loops, accessing the memory every time it loops, etc.
case (MSI_Scripts[Scripts[CurrentScript].Name].SkillConst) of
SKILL_WOODCUTTING: tObjects := Scripts[CurrentScript].Trees;
SKILL_MINING: tObjects := Scripts[CurrentScript].Rocks;
SKILL_FISHING: tObjects := Scripts[CurrentScript].FishSpots;
end;
repeat
while (not InvFull) do
begin
if not LoggedIn then break;
@Simba: Does simba have short circuit evaluation? Is PascalScript the limitation on it?
And yeh.. I'm currently looking for a bug in MSI :p (pickaxe drop)
~RM