mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-03 20:50:39 +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 }
|
extra exception frames }
|
||||||
procedure SetCodePage(var s : RawByteString; CodePage : TSystemCodePage; Convert : Boolean = True);
|
procedure SetCodePage(var s : RawByteString; CodePage : TSystemCodePage; Convert : Boolean = True);
|
||||||
begin
|
begin
|
||||||
if (S<>'') and (StringCodePage(S)<>CodePage) then
|
if (S='') or (PAnsiRec(pointer(S)-AnsiFirstOff)^.CodePage=CodePage) then
|
||||||
InternalSetCodePage(s,CodePage,Convert);
|
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;
|
end;
|
||||||
{$endif FPC_HAS_ANSISTR_SETCODEPAGE}
|
{$endif FPC_HAS_ANSISTR_SETCODEPAGE}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user