mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-14 12:39:31 +02:00
- Cleaned out STR_CONCAT_PROCS define
- i386-specific fpc_shortstr_append_shortstr removed too, because a) it was anyway disabled with STR_CONCAT_PROCS, b) the generic implementation is smaller and probably faster due to optimized Move(). git-svn-id: trunk@19867 -
This commit is contained in:
parent
40a9762ac6
commit
009ee271ec
@ -752,131 +752,6 @@ end;
|
||||
{$endif FPC_SYSTEM_HAS_FPC_SHORTSTR_ASSIGN}
|
||||
|
||||
|
||||
{$ifndef STR_CONCAT_PROCS}
|
||||
|
||||
{$ifndef FPC_SYSTEM_HAS_FPC_SHORTSTR_CONCAT}
|
||||
{$define FPC_SYSTEM_HAS_FPC_SHORTSTR_CONCAT}
|
||||
|
||||
function fpc_shortstr_concat(const s1,s2:shortstring):shortstring;compilerproc;
|
||||
begin
|
||||
asm
|
||||
{$ifdef FPC_PROFILE}
|
||||
push %eax
|
||||
push %edx
|
||||
push %ecx
|
||||
call mcount
|
||||
pop %ecx
|
||||
pop %edx
|
||||
pop %eax
|
||||
{$endif FPC_PROFILE}
|
||||
movl __RESULT,%edi
|
||||
movl %edi,%ebx
|
||||
movl s1,%esi { first string }
|
||||
lodsb
|
||||
andl $0x0ff,%eax
|
||||
stosb
|
||||
cmpl $7,%eax
|
||||
jl .LStrConcat1
|
||||
movl %edi,%ecx { Align on 32bits }
|
||||
negl %ecx
|
||||
andl $3,%ecx
|
||||
subl %ecx,%eax
|
||||
rep
|
||||
movsb
|
||||
movl %eax,%ecx
|
||||
andl $3,%eax
|
||||
shrl $2,%ecx
|
||||
rep
|
||||
movsl
|
||||
.LStrConcat1:
|
||||
movl %eax,%ecx
|
||||
rep
|
||||
movsb
|
||||
movl s2,%esi { second string }
|
||||
movzbl (%ebx),%ecx
|
||||
negl %ecx
|
||||
addl $0x0ff,%ecx
|
||||
lodsb
|
||||
cmpl %ecx,%eax
|
||||
jbe .LStrConcat2
|
||||
movl %ecx,%eax
|
||||
.LStrConcat2:
|
||||
addb %al,(%ebx)
|
||||
cmpl $7,%eax
|
||||
jl .LStrConcat3
|
||||
movl %edi,%ecx { Align on 32bits }
|
||||
negl %ecx
|
||||
andl $3,%ecx
|
||||
subl %ecx,%eax
|
||||
rep
|
||||
movsb
|
||||
movl %eax,%ecx
|
||||
andl $3,%eax
|
||||
shrl $2,%ecx
|
||||
rep
|
||||
movsl
|
||||
.LStrConcat3:
|
||||
movl %eax,%ecx
|
||||
rep
|
||||
movsb
|
||||
end ['EBX','ECX','EAX','ESI','EDI'];
|
||||
end;
|
||||
{$endif FPC_SYSTEM_HAS_FPC_SHORTSTR_CONCAT}
|
||||
|
||||
|
||||
{$ifndef FPC_SYSTEM_HAS_FPC_SHORTSTR_APPEND_SHORTSTR}
|
||||
{$define FPC_SYSTEM_HAS_FPC_SHORTSTR_APPEND_SHORTSTR}
|
||||
|
||||
procedure fpc_shortstr_append_shortstr(var s1:shortstring;const s2:shortstring);compilerproc;
|
||||
[public,alias:'FPC_SHORTSTR_APPEND_SHORTSTR'];
|
||||
begin
|
||||
asm
|
||||
{$ifdef FPC_PROFILE}
|
||||
push %eax
|
||||
push %edx
|
||||
push %ecx
|
||||
call mcount
|
||||
pop %ecx
|
||||
pop %edx
|
||||
pop %eax
|
||||
{$endif FPC_PROFILE}
|
||||
movl s1,%edi
|
||||
movl s2,%esi
|
||||
movl %edi,%ebx
|
||||
movzbl (%edi),%ecx
|
||||
movl __HIGH(s1),%eax
|
||||
lea 1(%edi,%ecx),%edi
|
||||
negl %ecx
|
||||
addl %eax,%ecx
|
||||
// no need to zero eax, high(s1) <= 255
|
||||
lodsb
|
||||
cmpl %ecx,%eax
|
||||
jbe .LStrConcat1
|
||||
movl %ecx,%eax
|
||||
.LStrConcat1:
|
||||
addb %al,(%ebx)
|
||||
cmpl $7,%eax
|
||||
jl .LStrConcat2
|
||||
movl %edi,%ecx { Align on 32bits }
|
||||
negl %ecx
|
||||
andl $3,%ecx
|
||||
subl %ecx,%eax
|
||||
rep
|
||||
movsb
|
||||
movl %eax,%ecx
|
||||
andl $3,%eax
|
||||
shrl $2,%ecx
|
||||
rep
|
||||
movsl
|
||||
.LStrConcat2:
|
||||
movl %eax,%ecx
|
||||
rep
|
||||
movsb
|
||||
end ['EBX','ECX','EAX','ESI','EDI'];
|
||||
end;
|
||||
{$endif FPC_SYSTEM_HAS_FPC_SHORTSTR_APPEND_SHORTSTR}
|
||||
|
||||
{$endif STR_CONCAT_PROCS}
|
||||
|
||||
{$ifndef FPC_SYSTEM_HAS_FPC_SHORTSTR_COMPARE}
|
||||
{$define FPC_SYSTEM_HAS_FPC_SHORTSTR_COMPARE}
|
||||
|
@ -138,62 +138,6 @@ end;
|
||||
{ alias for internal use }
|
||||
Procedure fpc_AnsiStr_Assign (Var S1 : Pointer;S2 : Pointer);[external name 'FPC_ANSISTR_ASSIGN'];
|
||||
|
||||
{$ifndef STR_CONCAT_PROCS}
|
||||
|
||||
function fpc_AnsiStr_Concat (const S1,S2 : AnsiString): ansistring; compilerproc;
|
||||
Var
|
||||
Size,Location : SizeInt;
|
||||
pc : PAnsiChar;
|
||||
begin
|
||||
{ only assign if s1 or s2 is empty }
|
||||
if (S1='') then
|
||||
begin
|
||||
result:=s2;
|
||||
exit;
|
||||
end;
|
||||
if (S2='') then
|
||||
begin
|
||||
result:=s1;
|
||||
exit;
|
||||
end;
|
||||
Location:=Length(S1);
|
||||
Size:=length(S2);
|
||||
SetLength(result,Size+Location);
|
||||
pc:=PAnsiChar(result);
|
||||
Move(S1[1],pc^,Location);
|
||||
inc(pc,location);
|
||||
Move(S2[1],pc^,Size+1);
|
||||
end;
|
||||
|
||||
|
||||
function fpc_AnsiStr_Concat_multi (const sarr:array of Ansistring): ansistring; compilerproc;
|
||||
Var
|
||||
i : Longint;
|
||||
p : pointer;
|
||||
pc : PAnsiChar;
|
||||
Size,NewLen : SizeInt;
|
||||
begin
|
||||
{ First calculate size of the result so we can do
|
||||
a single call to SetLength() }
|
||||
NewLen:=0;
|
||||
for i:=low(sarr) to high(sarr) do
|
||||
inc(NewLen,length(sarr[i]));
|
||||
SetLength(result,NewLen);
|
||||
pc:=PAnsiChar(result);
|
||||
for i:=low(sarr) to high(sarr) do
|
||||
begin
|
||||
p:=pointer(sarr[i]);
|
||||
if assigned(p) then
|
||||
begin
|
||||
Size:=length(ansistring(p));
|
||||
Move(PAnsiChar(p)^,pc^,Size+1);
|
||||
inc(pc,size);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{$else STR_CONCAT_PROCS}
|
||||
|
||||
procedure fpc_AnsiStr_Concat (var DestS:RawByteString;const S1,S2 : RawByteString{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}); compilerproc;
|
||||
Var
|
||||
Size,Location : SizeInt;
|
||||
@ -370,7 +314,6 @@ begin
|
||||
end;
|
||||
fpc_AnsiStr_Decr_Ref(destcopy);
|
||||
end;
|
||||
{$endif STR_CONCAT_PROCS}
|
||||
|
||||
|
||||
{$ifdef EXTRAANSISHORT}
|
||||
|
@ -38,12 +38,8 @@ Procedure fpc_freemem(p:pointer);compilerproc;
|
||||
procedure fpc_Shortstr_SetLength(var s:shortstring;len:SizeInt); compilerproc;
|
||||
procedure fpc_shortstr_to_shortstr(out res:shortstring; const sstr: shortstring); compilerproc;
|
||||
|
||||
{$ifndef STR_CONCAT_PROCS}
|
||||
function fpc_shortstr_concat(const s1,s2:shortstring): shortstring; compilerproc;
|
||||
{$else STR_CONCAT_PROCS}
|
||||
procedure fpc_shortstr_concat(var dests:shortstring;const s1,s2:shortstring);compilerproc;
|
||||
procedure fpc_shortstr_concat_multi(var dests:shortstring;const sarr:array of pshortstring);compilerproc;
|
||||
{$endif STR_CONCAT_PROCS}
|
||||
procedure fpc_shortstr_append_shortstr(var s1:shortstring;const s2:shortstring); compilerproc;
|
||||
function fpc_shortstr_compare(const left,right:shortstring) : longint; compilerproc;
|
||||
function fpc_shortstr_compare_equal(const left,right:shortstring) : longint; compilerproc;
|
||||
@ -213,13 +209,8 @@ Function fpc_Val_int64_UnicodeStr (Const S : UnicodeString; out Code : ValSInt):
|
||||
Procedure fpc_ansistr_decr_ref (Var S : Pointer); compilerproc;
|
||||
Procedure fpc_ansistr_incr_ref (S : Pointer); compilerproc;
|
||||
Procedure fpc_AnsiStr_Assign (Var DestS : Pointer;S2 : Pointer); compilerproc;
|
||||
{$ifdef STR_CONCAT_PROCS}
|
||||
Procedure fpc_AnsiStr_Concat (Var DestS : RawByteString;const S1,S2 : RawByteString{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}); compilerproc;
|
||||
Procedure fpc_AnsiStr_Concat_multi (Var DestS : RawByteString;const sarr:array of RawByteString{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}); compilerproc;
|
||||
{$else STR_CONCAT_PROCS}
|
||||
function fpc_AnsiStr_Concat (const S1,S2 : AnsiString): AnsiString; compilerproc;
|
||||
function fpc_AnsiStr_Concat_multi (const sarr:array of Ansistring): ansistring; compilerproc;
|
||||
{$endif STR_CONCAT_PROCS}
|
||||
{$ifdef EXTRAANSISHORT}
|
||||
Procedure fpc_AnsiStr_ShortStr_Concat (Var S1: AnsiString; Var S2 : ShortString); compilerproc;
|
||||
{$endif EXTRAANSISHORT}
|
||||
@ -267,13 +258,8 @@ Function fpc_ShortStr_To_WideStr (Const S2 : ShortString): WideString; compilerp
|
||||
Function fpc_WideStr_To_AnsiStr (const S2 : WideString{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}): AnsiString; compilerproc;
|
||||
Function fpc_AnsiStr_To_WideStr (Const S2 : RawByteString): WideString; compilerproc;
|
||||
Procedure fpc_WideStr_Assign (Var S1 : Pointer;S2 : Pointer); compilerproc;
|
||||
{$ifndef STR_CONCAT_PROCS}
|
||||
Function fpc_WideStr_Concat (const S1,S2 : WideString) : WideString; compilerproc;
|
||||
function fpc_WideStr_Concat_multi (const sarr:array of Widestring): widestring; compilerproc;
|
||||
{$else STR_CONCAT_PROCS}
|
||||
Procedure fpc_WideStr_Concat (Var DestS : Widestring;const S1,S2 : WideString); compilerproc;
|
||||
Procedure fpc_WideStr_Concat_multi (Var DestS : Widestring;const sarr:array of Widestring); compilerproc;
|
||||
{$endif STR_CONCAT_PROCS}
|
||||
Function fpc_Char_To_WideStr(const c : Char): WideString; compilerproc;
|
||||
Function fpc_PChar_To_WideStr(const p : pchar): WideString; compilerproc;
|
||||
Function fpc_CharArray_To_WideStr(const arr: array of char; zerobased: boolean = true): WideString; compilerproc;
|
||||
@ -319,13 +305,8 @@ Function fpc_AnsiStr_To_UnicodeStr (Const S2 : RawByteString): UnicodeString; co
|
||||
Function fpc_UnicodeStr_To_WideStr (const S2 : UnicodeString): WideString; compilerproc;
|
||||
Function fpc_WideStr_To_UnicodeStr (Const S2 : WideString): UnicodeString; compilerproc;
|
||||
Procedure fpc_UnicodeStr_Assign (Var S1 : Pointer;S2 : Pointer); compilerproc;
|
||||
{$ifndef STR_CONCAT_PROCS}
|
||||
Function fpc_UnicodeStr_Concat (const S1,S2 : UnicodeString) : UnicodeString; compilerproc;
|
||||
function fpc_UnicodeStr_Concat_multi (const sarr:array of Unicodestring): unicodestring; compilerproc;
|
||||
{$else STR_CONCAT_PROCS}
|
||||
Procedure fpc_UnicodeStr_Concat (Var DestS : Unicodestring;const S1,S2 : UnicodeString); compilerproc;
|
||||
Procedure fpc_UnicodeStr_Concat_multi (Var DestS : Unicodestring;const sarr:array of Unicodestring); compilerproc;
|
||||
{$endif STR_CONCAT_PROCS}
|
||||
Function fpc_Char_To_UnicodeStr(const c : Char): UnicodeString; compilerproc;
|
||||
Function fpc_PChar_To_UnicodeStr(const p : pchar): UnicodeString; compilerproc;
|
||||
Function fpc_CharArray_To_UnicodeStr(const arr: array of char; zerobased: boolean = true): UnicodeString; compilerproc;
|
||||
|
@ -891,24 +891,6 @@ end;
|
||||
{$endif ndef FPC_SYSTEM_HAS_FPC_SHORTSTR_ASSIGN}
|
||||
|
||||
{$ifndef FPC_SYSTEM_HAS_FPC_SHORTSTR_CONCAT}
|
||||
|
||||
{$ifndef STR_CONCAT_PROCS}
|
||||
|
||||
function fpc_shortstr_concat(const s1,s2:shortstring): shortstring;[public,alias:'FPC_SHORTSTR_CONCAT']; compilerproc;
|
||||
var
|
||||
s1l, s2l : byte;
|
||||
begin
|
||||
s1l:=length(s1);
|
||||
s2l:=length(s2);
|
||||
if s1l+s2l>255 then
|
||||
s2l:=255-s1l;
|
||||
move(s1[1],fpc_shortstr_concat[1],s1l);
|
||||
move(s2[1],fpc_shortstr_concat[s1l+1],s2l);
|
||||
fpc_shortstr_concat[0]:=chr(s1l+s2l);
|
||||
end;
|
||||
|
||||
{$else STR_CONCAT_PROCS}
|
||||
|
||||
procedure fpc_shortstr_concat(var dests:shortstring;const s1,s2:shortstring);compilerproc;
|
||||
var
|
||||
s1l, s2l : longint;
|
||||
@ -1001,9 +983,6 @@ begin
|
||||
if needtemp then
|
||||
DestS:=TmpStr;
|
||||
end;
|
||||
|
||||
{$endif STR_CONCAT_PROCS}
|
||||
|
||||
{$endif ndef FPC_SYSTEM_HAS_FPC_SHORTSTR_CONCAT}
|
||||
|
||||
|
||||
|
@ -457,62 +457,6 @@ end;
|
||||
{ alias for internal use }
|
||||
Procedure fpc_UnicodeStr_Assign (Var S1 : Pointer;S2 : Pointer);[external name 'FPC_UNICODESTR_ASSIGN'];
|
||||
|
||||
{$ifndef STR_CONCAT_PROCS}
|
||||
|
||||
function fpc_UnicodeStr_Concat (const S1,S2 : UnicodeString): UnicodeString; compilerproc;
|
||||
Var
|
||||
Size,Location : SizeInt;
|
||||
pc : punicodechar;
|
||||
begin
|
||||
{ only assign if s1 or s2 is empty }
|
||||
if (S1='') then
|
||||
begin
|
||||
result:=s2;
|
||||
exit;
|
||||
end;
|
||||
if (S2='') then
|
||||
begin
|
||||
result:=s1;
|
||||
exit;
|
||||
end;
|
||||
Location:=Length(S1);
|
||||
Size:=length(S2);
|
||||
SetLength(result,Size+Location);
|
||||
pc:=punicodechar(result);
|
||||
Move(S1[1],pc^,Location*sizeof(UnicodeChar));
|
||||
inc(pc,location);
|
||||
Move(S2[1],pc^,(Size+1)*sizeof(UnicodeChar));
|
||||
end;
|
||||
|
||||
|
||||
function fpc_UnicodeStr_Concat_multi (const sarr:array of Unicodestring): unicodestring; compilerproc;
|
||||
Var
|
||||
i : Longint;
|
||||
p : pointer;
|
||||
pc : punicodechar;
|
||||
Size,NewSize : SizeInt;
|
||||
begin
|
||||
{ First calculate size of the result so we can do
|
||||
a single call to SetLength() }
|
||||
NewSize:=0;
|
||||
for i:=low(sarr) to high(sarr) do
|
||||
inc(Newsize,length(sarr[i]));
|
||||
SetLength(result,NewSize);
|
||||
pc:=punicodechar(result);
|
||||
for i:=low(sarr) to high(sarr) do
|
||||
begin
|
||||
p:=pointer(sarr[i]);
|
||||
if assigned(p) then
|
||||
begin
|
||||
Size:=length(unicodestring(p));
|
||||
Move(punicodechar(p)^,pc^,(Size+1)*sizeof(UnicodeChar));
|
||||
inc(pc,size);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{$else STR_CONCAT_PROCS}
|
||||
|
||||
procedure fpc_UnicodeStr_Concat (var DestS:Unicodestring;const S1,S2 : UnicodeString); compilerproc;
|
||||
Var
|
||||
Size,Location : SizeInt;
|
||||
@ -619,7 +563,6 @@ begin
|
||||
fpc_UnicodeStr_Decr_Ref(destcopy);
|
||||
end;
|
||||
|
||||
{$endif STR_CONCAT_PROCS}
|
||||
|
||||
Function fpc_Char_To_UChar(const c : Char): UnicodeChar; compilerproc;
|
||||
var
|
||||
|
@ -305,61 +305,6 @@ end;
|
||||
{ alias for internal use }
|
||||
Procedure fpc_WideStr_Assign (Var S1 : Pointer;S2 : Pointer);[external name 'FPC_WIDESTR_ASSIGN'];
|
||||
|
||||
{$ifndef STR_CONCAT_PROCS}
|
||||
|
||||
function fpc_WideStr_Concat (const S1,S2 : WideString): WideString; compilerproc;
|
||||
Var
|
||||
Size,Location : SizeInt;
|
||||
pc : pwidechar;
|
||||
begin
|
||||
{ only assign if s1 or s2 is empty }
|
||||
if (S1='') then
|
||||
begin
|
||||
result:=s2;
|
||||
exit;
|
||||
end;
|
||||
if (S2='') then
|
||||
begin
|
||||
result:=s1;
|
||||
exit;
|
||||
end;
|
||||
Location:=Length(S1);
|
||||
Size:=length(S2);
|
||||
SetLength(result,Size+Location);
|
||||
pc:=pwidechar(result);
|
||||
Move(S1[1],pc^,Location*sizeof(WideChar));
|
||||
inc(pc,location);
|
||||
Move(S2[1],pc^,(Size+1)*sizeof(WideChar));
|
||||
end;
|
||||
|
||||
|
||||
function fpc_WideStr_Concat_multi (const sarr:array of Widestring): widestring; compilerproc;
|
||||
Var
|
||||
i : Longint;
|
||||
p : pointer;
|
||||
pc : pwidechar;
|
||||
Size,NewSize : SizeInt;
|
||||
begin
|
||||
{ First calculate size of the result so we can do
|
||||
a single call to SetLength() }
|
||||
NewSize:=0;
|
||||
for i:=low(sarr) to high(sarr) do
|
||||
inc(Newsize,length(sarr[i]));
|
||||
SetLength(result,NewSize);
|
||||
pc:=pwidechar(result);
|
||||
for i:=low(sarr) to high(sarr) do
|
||||
begin
|
||||
p:=pointer(sarr[i]);
|
||||
if assigned(p) then
|
||||
begin
|
||||
Size:=length(widestring(p));
|
||||
Move(pwidechar(p)^,pc^,(Size+1)*sizeof(WideChar));
|
||||
inc(pc,size);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{$else STR_CONCAT_PROCS}
|
||||
|
||||
procedure fpc_WideStr_Concat (var DestS:Widestring;const S1,S2 : WideString); compilerproc;
|
||||
Var
|
||||
@ -437,7 +382,6 @@ begin
|
||||
DestS:=DestTmp;
|
||||
end;
|
||||
|
||||
{$endif STR_CONCAT_PROCS}
|
||||
|
||||
|
||||
Function fpc_Char_To_WideStr(const c : Char): WideString; compilerproc;
|
||||
|
Loading…
Reference in New Issue
Block a user