SRL Archive - SRL Suggestions

Remove a func


Le Jingle

2012-12-16 01:37:58

I don't know why there are two functions that do the same thing (one built in simba, one in SRL), but I'd suggest one be removed.

Ex.
https://github.com/SRL/SRL-5/blob/master/SRL/core/symbol.simba#L896

function IsPointInTPA(Point: TPoint; TPA: TPointArray): Boolean;
var
I: LongInt;
begin
for I := High(TPA) downto 0 do
if (TPA[I].X = Point.X) then
if (TPA[I].Y = Point.Y) then
begin
Result:= True;
Exit;
end;
end;

&& …

https://github.com/MerlijnWajer/Simba/blob/master/Units/MMLCore/tpa.pas#L2082

function PointInTPA(const p: TPoint;const arP: TPointArray): Boolean;
var
i, l: Integer;
begin
l := High(arP);
if l < 0 then
Exit(false);
Result := True;
for i := 0 to l do
if (arP[i].x = p.x) and (arP[i].y = p.y) then
Exit;
Result := False;
end;

Justin

2012-12-16 01:43:00

Removing one could break scripts that use it

Le Jingle

2012-12-16 01:48:35

From: [J]ustin
Removing one could break scripts that use it


Well it'd be easy to re-route one another to a wrapper; however I'm more curious why they both exist (as opposed to -I think- only have a built in one)?

riwu

2012-12-16 04:33:47

From what i can see from the code IsPointInTPA() loops from the last TPA down to the first, while PointInTPA() does it the other way round.

IsPointInTPA() is probably rarely used since you would want to search from first TPA in most cases, and since it is in the module it's probably slower than using WizzyPlugin: PointInTPA(InvertTPA()) to search from right.

The best way would be to have an optional param reverse = False but Simba does not support it :(