* prevent going through (the expensive) InternalSetCodePage when changing

the code page of a string with refcount=1 and without conversion (happens
    a lot in internal RTL routines)

git-svn-id: trunk@24985 -
This commit is contained in:
Jonas Maebe 2013-06-27 13:11:57 +00:00
parent 277ae481b8
commit 345ca6f187

View File

@ -1409,8 +1409,12 @@ procedure InternalSetCodePage(var s : RawByteString; CodePage : TSystemCodePage;
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);
if (S='') or (PAnsiRec(pointer(S)-AnsiFirstOff)^.CodePage=CodePage) then
exit
else if not Convert and (PAnsiRec(pointer(S)-AnsiFirstOff)^.Ref=1) then
PAnsiRec(pointer(S)-AnsiFirstOff)^.CodePage:=CodePage
else
InternalSetCodePage(S,CodePage,Convert);
end;
{$endif FPC_HAS_ANSISTR_SETCODEPAGE}