mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-12 13:49:51 +02:00
+ procedure BufAppendString(TWideCharBuf,XMLString) for convenience
- removed {$ifdef fpc}, CompareMem is no longer slower than CompareWord, so it can be used always. git-svn-id: trunk@20417 -
This commit is contained in:
parent
bb2df48aa9
commit
0cd9e7fee9
@ -216,6 +216,7 @@ type
|
||||
procedure BufAllocate(var ABuffer: TWideCharBuf; ALength: Integer);
|
||||
procedure BufAppend(var ABuffer: TWideCharBuf; wc: WideChar);
|
||||
procedure BufAppendChunk(var ABuf: TWideCharBuf; pstart, pend: PWideChar);
|
||||
procedure BufAppendString(var ABuf: TWideCharBuf; const AValue: XMLString);
|
||||
function BufEquals(const ABuf: TWideCharBuf; const Arg: XMLString): Boolean;
|
||||
procedure BufNormalize(var Buf: TWideCharBuf; out Modified: Boolean);
|
||||
|
||||
@ -490,11 +491,7 @@ end;
|
||||
|
||||
function KeyCompare(const Key1: XMLString; Key2: Pointer; Key2Len: Integer): Boolean;
|
||||
begin
|
||||
{$IFDEF FPC}
|
||||
Result := (Length(Key1)=Key2Len) and (CompareWord(Pointer(Key1)^, Key2^, Key2Len) = 0);
|
||||
{$ELSE}
|
||||
Result := (Length(Key1)=Key2Len) and CompareMem(Pointer(Key1), Key2, Key2Len*2);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
{ THashTable }
|
||||
@ -972,6 +969,22 @@ begin
|
||||
Inc(ABuf.Length, Len);
|
||||
end;
|
||||
|
||||
procedure BufAppendString(var ABuf: TWideCharBuf; const AValue: XMLString);
|
||||
var
|
||||
Len: Integer;
|
||||
begin
|
||||
Len := Length(AValue);
|
||||
if Len <= 0 then
|
||||
Exit;
|
||||
if Len >= ABuf.MaxLength - ABuf.Length then
|
||||
begin
|
||||
ABuf.MaxLength := (Len + ABuf.Length)*2;
|
||||
ReallocMem(ABuf.Buffer, ABuf.MaxLength * sizeof(WideChar));
|
||||
end;
|
||||
Move(PWideChar(AValue)^, ABuf.Buffer[ABuf.Length], Len * sizeof(WideChar));
|
||||
Inc(ABuf.Length, Len);
|
||||
end;
|
||||
|
||||
function BufEquals(const ABuf: TWideCharBuf; const Arg: XMLString): Boolean;
|
||||
begin
|
||||
Result := (ABuf.Length = Length(Arg)) and
|
||||
|
Loading…
Reference in New Issue
Block a user