mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 16:38:02 +02:00
LazUtils: Optimize function UTF8StringReplace a little.
This commit is contained in:
parent
7b2f40cfb7
commit
277cc26bdc
@ -1211,9 +1211,9 @@ end;
|
|||||||
function UTF8StringReplace(const S, OldPattern, NewPattern: String;
|
function UTF8StringReplace(const S, OldPattern, NewPattern: String;
|
||||||
Flags: TReplaceFlags; out Count: Integer; const ALanguage: string=''): String;
|
Flags: TReplaceFlags; out Count: Integer; const ALanguage: string=''): String;
|
||||||
var
|
var
|
||||||
SrcS, OldPtrn, TempS: string;
|
SrcS, OldPtrn: string;
|
||||||
PSrc, POrig: PChar;
|
PSrc, POrig: PChar;
|
||||||
CharLen, OldPatLen: Integer;
|
CharLen, OldPatLen, l: Integer;
|
||||||
OkToReplace: Boolean;
|
OkToReplace: Boolean;
|
||||||
begin
|
begin
|
||||||
Count := 0;
|
Count := 0;
|
||||||
@ -1252,9 +1252,9 @@ begin
|
|||||||
Inc(PSrc, CharLen); // Next Codepoint
|
Inc(PSrc, CharLen); // Next Codepoint
|
||||||
// Copy a codepoint from original string and move forward
|
// Copy a codepoint from original string and move forward
|
||||||
CharLen := UTF8CodepointSize(POrig);
|
CharLen := UTF8CodepointSize(POrig);
|
||||||
SetLength(TempS{%H-}, CharLen);
|
l := Length(Result);
|
||||||
System.Move(POrig^, TempS[1], CharLen);
|
SetLength(Result, l+CharLen); // Copy one codepoint from original string
|
||||||
Result := Result + TempS; // Copy one codepoint from original string
|
System.Move(POrig^, Result[l+1], CharLen);
|
||||||
Inc(POrig, CharLen); // Next Codepoint
|
Inc(POrig, CharLen); // Next Codepoint
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user