I'm one of these persons, those scripted not really efficient. So it's like: I didn't payed attention how I script something, as long as this works. So but now I need to find out, how I can improve them more and more by some small changes, like: If a part of a script needs 2 seconds and I could reduce the calculation time to 1,5 seconds so it would be awesome. Does someone know a way for this?
Well and another thing that I wanted to introduce with this Topic: A discussion about my "Version" of explode
- I call it CSplit:
function CSplit(Source: string; const Cut: string): array of string;
var
rep: integer;
begin
repeat
SetArrayLength(Result, rep + 1);
Result[rep] := GetPiece(Source,Cut,rep);
inc(rep,1);
until (Result[rep-1] = NIL);
SetArrayLength(Result, rep - 1);
end;
It uses some less variables than explode, but i'm not sure of the speed of this function. But it works exactly like explode. Maybe someone could compare those 2 functions... I'm using a Server where REALLY much datas are loaded, so every single improvement could help me (and for sure other people also).
ExHunter
EDIT: This seems to be a improvement:
function CSplit(Source: string; const Cut: string): array of string;
var
rep: integer;
begin
rep := -1;
repeat
inc(rep,1);
SetArrayLength(Result, rep + 1);
Result[rep] := GetPiece(Source,Cut,rep);
until (Result[rep] = NIL);
SetArrayLength(Result, rep);
end;