mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 06:29:32 +02:00
rtl: don't perform unneeded string conversions if string codepage matches codepage to convert (thanks to Sergey)
git-svn-id: trunk@21987 -
This commit is contained in:
parent
562a45f2e1
commit
1af45d7ec0
@ -702,14 +702,17 @@ begin
|
||||
SLen:=Length(s);
|
||||
If Len>SLen Then
|
||||
fpc_WriteBlanks(f,Len-SLen);
|
||||
if slen > 0 then
|
||||
if SLen > 0 then
|
||||
begin
|
||||
{$if defined(FPC_HAS_CPSTRING) and defined(FPC_HAS_FEATURE_ANSISTRINGS)}
|
||||
a:=fpc_AnsiStr_To_AnsiStr(S,TextRec(f).CodePage);
|
||||
fpc_WriteBuffer(f,PAnsiChar(a)^,Length(a));
|
||||
{$else}
|
||||
fpc_WriteBuffer(f,PAnsiChar(s)^,SLen);
|
||||
if TextRec(f).CodePage<>StringCodePage(S) then
|
||||
begin
|
||||
a:=fpc_AnsiStr_To_AnsiStr(S,TextRec(f).CodePage);
|
||||
fpc_WriteBuffer(f,PAnsiChar(a)^,Length(a));
|
||||
end
|
||||
else
|
||||
{$endif}
|
||||
fpc_WriteBuffer(f,PAnsiChar(s)^,SLen);
|
||||
end;
|
||||
end;
|
||||
fmInput: InOutRes:=105
|
||||
@ -1344,7 +1347,8 @@ Begin
|
||||
SetLength(s,Slen);
|
||||
{$ifdef FPC_HAS_CPSTRING}
|
||||
SetCodePage(s,TextRec(f).CodePage,false);
|
||||
s:=fpc_AnsiStr_To_AnsiStr(s,cp);
|
||||
if cp<>TextRec(f).CodePage then
|
||||
s:=fpc_AnsiStr_To_AnsiStr(s,cp);
|
||||
{$endif FPC_HAS_CPSTRING}
|
||||
End;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user