소스 검색

* split SetCodePage into a wrapper and a function doing the real work to get rid of exception frames in the simple case

git-svn-id: trunk@24942 -
florian 12 년 전
부모
커밋
00b03de7f0
1개의 변경된 파일11개의 추가작업 그리고 4개의 파일을 삭제
  1. 11 4
      rtl/inc/astrings.inc

+ 11 - 4
rtl/inc/astrings.inc

@@ -1386,11 +1386,9 @@ function StringRefCount(const S: RawByteString): SizeInt; overload;
 
 {$ifndef FPC_HAS_ANSISTR_SETCODEPAGE}
 {$define FPC_HAS_ANSISTR_SETCODEPAGE}
-procedure SetCodePage(var s : RawByteString; CodePage : TSystemCodePage; Convert : Boolean = True);
+procedure InternalSetCodePage(var s : RawByteString; CodePage : TSystemCodePage; Convert : Boolean = True);
   begin
-    if (S='') or (StringCodePage(S)=CodePage) then
-      exit
-    else if Convert then
+    if Convert then
       begin
 {$ifdef FPC_HAS_CPSTRING}
         s:=fpc_AnsiStr_To_AnsiStr(s,CodePage);
@@ -1405,6 +1403,15 @@ procedure SetCodePage(var s : RawByteString; CodePage : TSystemCodePage; Convert
         PAnsiRec(pointer(s)-AnsiFirstOff)^.CodePage:=CodePage;
       end;
   end;
+
+
+{ use this wrapper for the simple case to avoid the generation of a temp. ansistring which causes
+  extra exception frames }
+procedure SetCodePage(var s : RawByteString; CodePage : TSystemCodePage; Convert : Boolean = True);
+  begin
+    if (S<>'') and (StringCodePage(S)<>CodePage) then
+      InternalSetCodePage(s,CodePage,Convert);
+  end;
 {$endif FPC_HAS_ANSISTR_SETCODEPAGE}