mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-16 08:00:52 +02:00
* 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:
parent
277ae481b8
commit
345ca6f187
@ -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}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user