Форум: "KOL";
Текущий архив: 2010.08.27;
Скачать: [xml.tar.bz2];
Вниз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 вся ветка
Форум: "KOL";
Текущий архив: 2010.08.27;
Скачать: [xml.tar.bz2];
Память: 0.45 MB
Время: 0.085 c