Browse Source

* reverted inline patch partly
* improved append_char by avoiding unnecessary unique call

git-svn-id: trunk@1406 -

florian 20 years ago
parent
commit
d8acc80ae5
1 changed files with 23 additions and 24 deletions
  1. 23 24
      rtl/inc/astrings.inc

+ 23 - 24
rtl/inc/astrings.inc

@@ -52,7 +52,7 @@ Const
 
 
 
 
 
 
-Function NewAnsiString(Len : SizeInt) : Pointer; 
+Function NewAnsiString(Len : SizeInt) : Pointer;
 {
 {
   Allocate a new AnsiString on the heap.
   Allocate a new AnsiString on the heap.
   initialize it to zero length and reference count 1.
   initialize it to zero length and reference count 1.
@@ -85,7 +85,7 @@ begin
   S:=Nil;
   S:=Nil;
 end;
 end;
 
 
-Procedure fpc_AnsiStr_Decr_Ref (Var S : Pointer); [Public,Alias:'FPC_ANSISTR_DECR_REF'];  compilerproc; {$IFNDEF VER2_0} Inline; {$ENDIF}
+Procedure fpc_AnsiStr_Decr_Ref (Var S : Pointer); [Public,Alias:'FPC_ANSISTR_DECR_REF'];  compilerproc;
 {
 {
   Decreases the ReferenceCount of a non constant ansistring;
   Decreases the ReferenceCount of a non constant ansistring;
   If the reference count is zero, deallocate the string;
   If the reference count is zero, deallocate the string;
@@ -98,7 +98,7 @@ Begin
   { Zero string }
   { Zero string }
   If S=Nil then exit;
   If S=Nil then exit;
   { check for constant strings ...}
   { check for constant strings ...}
-  l:=@PANSIREC(S-FirstOff)^.Ref;
+  l:=@PAnsiRec(S-FirstOff)^.Ref;
   If l^<0 then exit;
   If l^<0 then exit;
   { declocked does a MT safe dec and returns true, if the counter is 0 }
   { declocked does a MT safe dec and returns true, if the counter is 0 }
   If declocked(l^) then
   If declocked(l^) then
@@ -417,13 +417,13 @@ Var
   L    : SizeInt;
   L    : SizeInt;
 
 
 begin
 begin
-     L:=PAnsiRec(Pointer(S)-FirstOff)^.len;
-     SNew:=NewAnsiString (L);
-     Move (Pointer(S)^,SNew^,L+1);
-     PAnsiRec(SNew-FirstOff)^.len:=L;
-     fpc_ansistr_decr_ref (Pointer(S));  { Thread safe }
-     pointer(S):=SNew;
-     pointer(result):=SNew;
+  L:=PAnsiRec(Pointer(S)-FirstOff)^.len;
+  SNew:=NewAnsiString (L);
+  Move (Pointer(S)^,SNew^,L+1);
+  PAnsiRec(SNew-FirstOff)^.len:=L;
+  fpc_ansistr_decr_ref (Pointer(S));  { Thread safe }
+  pointer(S):=SNew;
+  pointer(result):=SNew;
 end;
 end;
 
 
 // MV: inline the basic checks for case that S is already unique.
 // MV: inline the basic checks for case that S is already unique.
@@ -441,14 +441,15 @@ begin
     result:=fpc_truely_ansistr_unique(s);
     result:=fpc_truely_ansistr_unique(s);
 end;
 end;
 
 
-Procedure fpc_ansistr_append_char(Var S : AnsiString;c : char); [Public,Alias : 'FPC_ANSISTR_APPEND_CHAR']; compilerproc; {$IFNDEF VER2_0} Inline; {$ENDIF}
+Procedure fpc_ansistr_append_char(Var S : AnsiString;c : char); [Public,Alias : 'FPC_ANSISTR_APPEND_CHAR']; compilerproc;
 begin
 begin
-   SetLength(S,length(S)+1);
-   S[length(S)]:=c;
-   PByte(Pointer(S)+length(S))^:=0; { Terminating Zero }
+  SetLength(S,length(S)+1);
+  // avoid unique call
+  PChar(Pointer(S)+length(S)-1)^:=c;
+  PByte(Pointer(S)+length(S))^:=0; { Terminating Zero }
 end;
 end;
 
 
-Procedure fpc_ansistr_append_shortstring(Var S : AnsiString;Str : ShortString); [Public,Alias : 'FPC_ANSISTR_APPEND_SHORTSTRING']; compilerproc; 
+Procedure fpc_ansistr_append_shortstring(Var S : AnsiString;Str : ShortString); [Public,Alias : 'FPC_ANSISTR_APPEND_SHORTSTRING']; compilerproc;
 var
 var
    ofs : SizeInt;
    ofs : SizeInt;
 begin
 begin
@@ -575,7 +576,7 @@ begin
 end;
 end;
 
 
 
 
-Function fpc_Val_Real_AnsiStr(Const S : AnsiString; Var Code : ValSInt): ValReal; [public, alias:'FPC_VAL_REAL_ANSISTR']; compilerproc; {$IFNDEF VER2_0} Inline; {$ENDIF}
+Function fpc_Val_Real_AnsiStr(Const S : AnsiString; Var Code : ValSInt): ValReal; [public, alias:'FPC_VAL_REAL_ANSISTR']; compilerproc;
 Var
 Var
   SS : String;
   SS : String;
 begin
 begin
@@ -590,7 +591,7 @@ begin
 end;
 end;
 
 
 
 
-Function fpc_Val_UInt_AnsiStr (Const S : AnsiString; Var Code : ValSInt): ValUInt; [public, alias:'FPC_VAL_UINT_ANSISTR']; compilerproc; {$IFNDEF VER2_0} Inline; {$ENDIF}
+Function fpc_Val_UInt_AnsiStr (Const S : AnsiString; Var Code : ValSInt): ValUInt; [public, alias:'FPC_VAL_UINT_ANSISTR']; compilerproc;
 Var
 Var
   SS : ShortString;
   SS : ShortString;
 begin
 begin
@@ -605,7 +606,7 @@ begin
 end;
 end;
 
 
 
 
-Function fpc_Val_SInt_AnsiStr (DestSize: SizeInt; Const S : AnsiString; Var Code : ValSInt): ValSInt; [public, alias:'FPC_VAL_SINT_ANSISTR']; compilerproc; {$IFNDEF VER2_0} Inline; {$ENDIF}
+Function fpc_Val_SInt_AnsiStr (DestSize: SizeInt; Const S : AnsiString; Var Code : ValSInt): ValSInt; [public, alias:'FPC_VAL_SINT_ANSISTR']; compilerproc;
 Var
 Var
   SS : ShortString;
   SS : ShortString;
 begin
 begin
@@ -622,7 +623,7 @@ end;
 
 
 {$ifndef CPU64}
 {$ifndef CPU64}
 
 
-Function fpc_Val_qword_AnsiStr (Const S : AnsiString; Var Code : ValSInt): qword; [public, alias:'FPC_VAL_QWORD_ANSISTR']; compilerproc; {$IFNDEF VER2_0} Inline; {$ENDIF}
+Function fpc_Val_qword_AnsiStr (Const S : AnsiString; Var Code : ValSInt): qword; [public, alias:'FPC_VAL_QWORD_ANSISTR']; compilerproc;
 Var
 Var
   SS : ShortString;
   SS : ShortString;
 begin
 begin
@@ -637,7 +638,7 @@ begin
 end;
 end;
 
 
 
 
-Function fpc_Val_int64_AnsiStr (Const S : AnsiString; Var Code : ValSInt): Int64; [public, alias:'FPC_VAL_INT64_ANSISTR']; compilerproc; {$IFNDEF VER2_0} Inline; {$ENDIF}
+Function fpc_Val_int64_AnsiStr (Const S : AnsiString; Var Code : ValSInt): Int64; [public, alias:'FPC_VAL_INT64_ANSISTR']; compilerproc;
 Var
 Var
   SS : ShortString;
   SS : ShortString;
 begin
 begin
@@ -714,8 +715,8 @@ begin
      Size:=LS-Index+1;
      Size:=LS-Index+1;
   If (Size<=LS-Index) then
   If (Size<=LS-Index) then
     begin
     begin
-    Dec(Index);
-    Move(PByte(Pointer(S))[Index+Size],PByte(Pointer(S))[Index],LS-Index-Size+1);
+      Dec(Index);
+      Move(PByte(Pointer(S))[Index+Size],PByte(Pointer(S))[Index],LS-Index-Size+1);
     end;
     end;
   Setlength(S,LS-Size);
   Setlength(S,LS-Size);
 end;
 end;
@@ -779,5 +780,3 @@ begin
   for i := 1 to length (s) do
   for i := 1 to length (s) do
     result[i] := lowercase(s[i]);
     result[i] := lowercase(s[i]);
 end;
 end;
-
-