mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 19:19:19 +02:00
- Removed unnecessary operations: SetLength before widestringmanager calls (widestringmanager does the allocation) and zero-termination after SetLength (SetLength does zero-termination).
git-svn-id: trunk@19483 -
This commit is contained in:
parent
b36a930f26
commit
018fdaf839
@ -383,11 +383,7 @@ begin
|
||||
Size := IndexWord(p^, -1, 0);
|
||||
Setlength(result,Size);
|
||||
if Size>0 then
|
||||
begin
|
||||
Move(p^,PUnicodeChar(Pointer(result))^,Size*sizeof(UnicodeChar));
|
||||
{ Terminating Zero }
|
||||
PUnicodeChar(Pointer(result)+Size*sizeof(UnicodeChar))^:=#0;
|
||||
end;
|
||||
Move(p^,PUnicodeChar(Pointer(result))^,Size*sizeof(UnicodeChar));
|
||||
end;
|
||||
|
||||
|
||||
@ -401,11 +397,7 @@ begin
|
||||
Size := IndexWord(p^, -1, 0);
|
||||
Setlength(result,Size);
|
||||
if Size>0 then
|
||||
begin
|
||||
Move(p^,PUnicodeChar(Pointer(result))^,Size*sizeof(UnicodeChar));
|
||||
{ Terminating Zero }
|
||||
PUnicodeChar(Pointer(result)+Size*sizeof(UnicodeChar))^:=#0;
|
||||
end;
|
||||
Move(p^,PUnicodeChar(Pointer(result))^,Size*sizeof(UnicodeChar));
|
||||
end;
|
||||
|
||||
|
||||
|
@ -82,18 +82,6 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
(*
|
||||
Procedure UniqueWideString(Var S : WideString); [Public,Alias : 'FPC_WIDESTR_UNIQUE'];
|
||||
{
|
||||
Make sure reference count of S is 1,
|
||||
using copy-on-write semantics.
|
||||
}
|
||||
|
||||
begin
|
||||
end;
|
||||
*)
|
||||
|
||||
|
||||
{****************************************************************************
|
||||
Internal functions, not in interface.
|
||||
****************************************************************************}
|
||||
@ -242,11 +230,7 @@ begin
|
||||
result:='';
|
||||
Size:=Length(S2);
|
||||
if Size>0 then
|
||||
begin
|
||||
widestringmanager.Ansi2WideMoveProc(PChar(@S2[1]),DefaultSystemCodePage,result,Size);
|
||||
{ Terminating Zero }
|
||||
PWideChar(Pointer(fpc_ShortStr_To_WideStr)+Size*sizeof(WideChar))^:=#0;
|
||||
end;
|
||||
widestringmanager.Ansi2WideMoveProc(PChar(@S2[1]),DefaultSystemCodePage,result,Size);
|
||||
end;
|
||||
|
||||
|
||||
@ -302,13 +286,9 @@ begin
|
||||
if p=nil then
|
||||
exit;
|
||||
Size := IndexWord(p^, -1, 0);
|
||||
Setlength(result,Size);
|
||||
Setlength(result,Size); // zero-terminates
|
||||
if Size>0 then
|
||||
begin
|
||||
Move(p^,PWideChar(Pointer(result))^,Size*sizeof(WideChar));
|
||||
{ Terminating Zero }
|
||||
PWideChar(Pointer(result)+Size*sizeof(WideChar))^:=#0;
|
||||
end;
|
||||
Move(p^,PWideChar(Pointer(result))^,Size*sizeof(WideChar));
|
||||
end;
|
||||
|
||||
|
||||
@ -488,8 +468,6 @@ Function fpc_Char_To_WideStr(const c : Char): WideString; compilerproc;
|
||||
begin
|
||||
Setlength(fpc_Char_To_WideStr,1);
|
||||
fpc_Char_To_WideStr[1]:=c;
|
||||
{ Terminating Zero }
|
||||
PWideChar(Pointer(fpc_Char_To_WideStr)+sizeof(WideChar))^:=#0;
|
||||
end;
|
||||
|
||||
|
||||
@ -553,7 +531,6 @@ begin
|
||||
end
|
||||
else
|
||||
i := high(arr)+1;
|
||||
SetLength(fpc_CharArray_To_WideStr,i);
|
||||
widestringmanager.Ansi2WideMoveProc(pchar(@arr),DefaultSystemCodePage,fpc_CharArray_To_WideStr,i);
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user