Autor Beitrag
mohfa
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Do 25.02.10 15:53 
Hi all, I want to optimize this function ; is there any other better alternative :

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
function StringToken(const line: Pointer; Fieldno: Integer; const delim: Char; var Fields, Linepos: Integer): String;
var
    counter, cn: integer;
    cur: char;
    i, ln: integer;
begin
    result  := '';
    counter := fields;
    cn      := 0;
    ln      := length(string(line^));

    for i := linepos to ln do begin
        cur := string(line^)[i];
        if cur = delim then begin
            asm inc counter end;
            if counter > fieldno then begin
                Result := copy(string(line^), linepos, cn);

                linepos := i;
                fields  := counter - 1;
                exit;
            end else begin
                linepos := i + 1;
                Continue;
            end;
        end;
        if fieldno = counter then
            inc(cn);
        
    end;
    Result := copy(string(line^), linepos, cn);
    linepos := i + 1;
    fields  := counter - 1;

end;


many thanks
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Fr 26.02.10 20:18 
Use the version from the Fast Code project you included in your project anyways.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
mohfa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Fr 26.02.10 21:44 
Thank you BenBE .... :)