瀏覽代碼

* Removed 'inline' attribute from 6 overloaded pos() functions which contain a managed typecast. Inlining it leads to noticeable increase in code size without any sensible speed improvement.
* Added 'const' modifier to the first argument of these functions in order to avoid creating a local copy.

git-svn-id: trunk@20207 -

sergei 13 年之前
父節點
當前提交
7ff76caa73
共有 4 個文件被更改,包括 16 次插入13 次删除
  1. 3 3
      rtl/inc/ustringh.inc
  2. 5 3
      rtl/inc/ustrings.inc
  3. 3 3
      rtl/inc/wstringh.inc
  4. 5 4
      rtl/inc/wstrings.inc

+ 3 - 3
rtl/inc/ustringh.inc

@@ -19,9 +19,9 @@ Procedure UniqueString (Var S : UnicodeString);external name 'FPC_UNICODESTR_UNI
 Function Pos (Const Substr : UnicodeString; Const Source : UnicodeString) : SizeInt;
 Function Pos (c : Char; Const s : UnicodeString) : SizeInt;
 Function Pos (c : UnicodeChar; Const s : UnicodeString) : SizeInt;
-Function Pos (c : RawByteString; Const s : UnicodeString) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
-Function Pos (c : UnicodeString; Const s : RawByteString) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
-Function Pos (c : ShortString; Const s : UnicodeString) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function Pos (const c : RawByteString; Const s : UnicodeString) : SizeInt;
+Function Pos (const c : UnicodeString; Const s : RawByteString) : SizeInt;
+Function Pos (const c : ShortString; Const s : UnicodeString) : SizeInt;
 
 Function UpCase(const s : UnicodeString) : UnicodeString;
 Function  UpCase(c:UnicodeChar):UnicodeChar;

+ 5 - 3
rtl/inc/ustrings.inc

@@ -1331,19 +1331,21 @@ begin
 end;
 
 
-Function Pos (c : RawByteString; Const s : UnicodeString) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+{ DO NOT inline these! Inlining a managed typecast creates an implicit try..finally
+  block, which is significant bloat without any sensible speed improvement. }
+Function Pos (const c : RawByteString; Const s : UnicodeString) : SizeInt;
   begin
     result:=Pos(UnicodeString(c),s);
   end;
 
 
-Function Pos (c : ShortString; Const s : UnicodeString) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function Pos (const c : ShortString; Const s : UnicodeString) : SizeInt;
   begin
     result:=Pos(UnicodeString(c),s);
   end;
 
 
-Function Pos (c : UnicodeString; Const s : RawByteString) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function Pos (const c : UnicodeString; Const s : RawByteString) : SizeInt;
   begin
     result:=Pos(c,UnicodeString(s));
   end;

+ 3 - 3
rtl/inc/wstringh.inc

@@ -20,9 +20,9 @@ Function Pos (Const Substr : WideString; Const Source : WideString) : SizeInt;
 Function Pos (c : Char; Const s : WideString) : SizeInt;
 Function Pos (c : WideChar; Const s : WideString) : SizeInt;
 Function Pos (c : WideChar; Const s : RawByteString) : SizeInt;
-Function Pos (c : RawByteString; Const s : WideString) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
-Function Pos (c : WideString; Const s : RawByteString) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
-Function Pos (c : ShortString; Const s : WideString) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function Pos (const c : RawByteString; Const s : WideString) : SizeInt;
+Function Pos (const c : WideString; Const s : RawByteString) : SizeInt;
+Function Pos (const c : ShortString; Const s : WideString) : SizeInt;
 
 Function UpCase(const s : WideString) : WideString;
 

+ 5 - 4
rtl/inc/wstrings.inc

@@ -712,26 +712,27 @@ begin
   pos:=0;
 end;
 
-
+{ DO NOT inline these! Inlining a managed typecast creates an implicit try..finally
+  block, which is significant bloat without any sensible speed improvement. }
 Function Pos (c : WideChar; Const s : RawByteString) : SizeInt;
   begin
     result:=Pos(c,WideString(s));
   end;
 
 
-Function Pos (c : RawByteString; Const s : WideString) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function Pos (const c : RawByteString; Const s : WideString) : SizeInt;
   begin
     result:=Pos(WideString(c),s);
   end;
 
 
-Function Pos (c : ShortString; Const s : WideString) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function Pos (const c : ShortString; Const s : WideString) : SizeInt;
   begin
     result:=Pos(WideString(c),s);
   end;
 
 
-Function Pos (c : WideString; Const s : RawByteString) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function Pos (const c : WideString; Const s : RawByteString) : SizeInt;
   begin
     result:=Pos(c,WideString(s));
   end;