mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 04:09:15 +02:00
* DefaultUnicode2AnsiMove, DefaultAnsi2UnicodeMove: replaced indexed access to destination string by pointer access, this eliminates numerous unnecessary calls to fpc_xxxstring_unique.
git-svn-id: trunk@16233 -
This commit is contained in:
parent
791cb74f22
commit
f2260c1549
@ -48,7 +48,7 @@ Const
|
|||||||
|
|
||||||
{
|
{
|
||||||
Default UnicodeChar <-> Char conversion is to only convert the
|
Default UnicodeChar <-> Char conversion is to only convert the
|
||||||
lower 127 chars, all others are translated to spaces.
|
lower 127 chars, all others are translated to '?'.
|
||||||
|
|
||||||
These routines can be overwritten for the Current Locale
|
These routines can be overwritten for the Current Locale
|
||||||
}
|
}
|
||||||
@ -56,15 +56,18 @@ Const
|
|||||||
procedure DefaultUnicode2AnsiMove(source:punicodechar;var dest:ansistring;len:SizeInt);
|
procedure DefaultUnicode2AnsiMove(source:punicodechar;var dest:ansistring;len:SizeInt);
|
||||||
var
|
var
|
||||||
i : SizeInt;
|
i : SizeInt;
|
||||||
|
p : PAnsiChar;
|
||||||
begin
|
begin
|
||||||
setlength(dest,len);
|
setlength(dest,len);
|
||||||
|
p:=pointer(dest); {SetLength guarantees that dest is unique}
|
||||||
for i:=1 to len do
|
for i:=1 to len do
|
||||||
begin
|
begin
|
||||||
if word(source^)<256 then
|
if word(source^)<256 then
|
||||||
dest[i]:=char(word(source^))
|
p^:=char(word(source^))
|
||||||
else
|
else
|
||||||
dest[i]:='?';
|
p^:='?';
|
||||||
inc(source);
|
inc(source);
|
||||||
|
inc(p);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -72,12 +75,15 @@ end;
|
|||||||
procedure DefaultAnsi2UnicodeMove(source:pchar;var dest:unicodestring;len:SizeInt);
|
procedure DefaultAnsi2UnicodeMove(source:pchar;var dest:unicodestring;len:SizeInt);
|
||||||
var
|
var
|
||||||
i : SizeInt;
|
i : SizeInt;
|
||||||
|
p : PUnicodeChar;
|
||||||
begin
|
begin
|
||||||
setlength(dest,len);
|
setlength(dest,len);
|
||||||
|
p:=pointer(dest); {SetLength guarantees that dest is unique}
|
||||||
for i:=1 to len do
|
for i:=1 to len do
|
||||||
begin
|
begin
|
||||||
dest[i]:=unicodechar(byte(source^));
|
p^:=unicodechar(byte(source^));
|
||||||
inc(source);
|
inc(source);
|
||||||
|
inc(p);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user