Вниз
Скачать: CL | DM;

KOL Format/wvsprintf performance hit   Найти похожие ветки 

 
Freeman ©   (2008-07-14 02:59) [0]

function Format(const Fmt: string; const Args: array of const): string;
asm
       PUSH    ESI
       PUSH    EDI
       PUSH    EBX
       MOV     EBX, ESP
       ADD     ESP, -2048
       MOV     ESI, ESP

       INC     ECX
       JZ      @@2
@@1:
       MOV     EDI, [EDX + ECX*8 - 8]
       PUSH    EDI
       LOOP    @@1
@@2:
       PUSH    ESP
       PUSH    EAX
       PUSH    ESI

       CALL    wvsprintf

       MOV     EDX, ESI
       MOV     ECX, EAX                   // by Freeman
       MOV     EAX, @Result
       CALL    System.@LStrFromPCharLen   // by Freeman, performance hit

       MOV     ESP, EBX
       POP     EBX
       POP     EDI
       POP     ESI
end;


 
Thaddy   (2008-07-14 11:48) [1]

Not really strange:

I suppose you are using the unicode version of wvsprintf?
In that case you should call LStrFromPWCharLen.
Otherwise you get a performance hit because the unicodestring gets converted to string in the background by the OS.

Also it is a good idea to use kolstring instead of string.


 
Freeman ©   (2008-07-15 02:34) [2]

He-he. In my project (not KOL-based) I"m using these snippets:

function FormatBuf(Fmt: PAnsiChar; Args: array of const; Buf: PAnsiChar): Integer;
asm
       PUSH    EDI

       INC     ECX
       JZ      @@2
@@1:
       MOV     EDI, [EDX + ECX*8 - 8]
       PUSH    EDI
       LOOP    @@1
@@2:
       PUSH    ESP
       PUSH    EAX
       MOV     EDI, Buf
       PUSH    EDI
       CALL    wvsprintfA

       POP     EDI
end;

function WideFormatBuf(Fmt: PWideChar; Args: array of const; Buf: PWideChar): Integer;
asm
       PUSH    EDI

       INC     ECX
       JZ      @@2
@@1:
       MOV     EDI, [EDX + ECX*8 - 8]
       PUSH    EDI
       LOOP    @@1
@@2:
       PUSH    ESP
       PUSH    EAX
       MOV     EDI, Buf
       PUSH    EDI
       CALL    wvsprintfW

       POP     EDI
end;


 
Thaddy   (2008-07-21 17:38) [3]

This would be a start to work with kol strings.

function FormatBuf(Fmt: PAnsiChar; Args: array of const; Buf: PAnsiChar): Integer;overload;
asm
      PUSH    EDI

      INC     ECX
      JZ      @@2
@@1:
      MOV     EDI, [EDX + ECX*8 - 8]
      PUSH    EDI
      LOOP    @@1
@@2:
      PUSH    ESP
      PUSH    EAX
      MOV     EDI, Buf
      PUSH    EDI
      CALL    wvsprintfA

      POP     EDI
end;

function FormatBuf(Fmt: PWideChar; Args: array of const; Buf: PWideChar): Integer;overload;
asm
      PUSH    EDI

      INC     ECX
      JZ      @@2
@@1:
      MOV     EDI, [EDX + ECX*8 - 8]
      PUSH    EDI
      LOOP    @@1
@@2:
      PUSH    ESP
      PUSH    EAX
      MOV     EDI, Buf
      PUSH    EDI
      CALL    wvsprintfW

      POP     EDI
end;



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.46 MB
Время: 0.042 c
15-1267433395
12
2010-03-01 11:49
2010.08.27
Опрос. Сколько уже потратили на бесплатное образование детей?


15-1269379803
Юрий
2010-03-24 00:30
2010.08.27
С днем рождения ! 24 марта 2010 среда


15-1267286593
KilkennyCat
2010-02-27 19:03
2010.08.27
про американцев


15-1269123425
tri3
2010-03-21 01:17
2010.08.27
Оформление патента


15-1269981002
Юрий
2010-03-31 00:30
2010.08.27
С днем рождения ! 31 марта 2010 среда




   Наверх