From 018fdaf839ddea38b2a1c3cc79a87633980a1f59 Mon Sep 17 00:00:00 2001 From: sergei Date: Thu, 13 Oct 2011 17:10:12 +0000 Subject: [PATCH] - 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 - --- rtl/inc/ustrings.inc | 12 ++---------- rtl/inc/wstrings.inc | 29 +++-------------------------- 2 files changed, 5 insertions(+), 36 deletions(-) diff --git a/rtl/inc/ustrings.inc b/rtl/inc/ustrings.inc index f3208132ba..920bbd3177 100644 --- a/rtl/inc/ustrings.inc +++ b/rtl/inc/ustrings.inc @@ -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; diff --git a/rtl/inc/wstrings.inc b/rtl/inc/wstrings.inc index 92bcd8d98a..8491ae10b3 100644 --- a/rtl/inc/wstrings.inc +++ b/rtl/inc/wstrings.inc @@ -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;