Just as a matter of interest, I came up with my own fast method working
along the lines of John's method but I think this is tidier.
type
TBuffer32 = array[0..0] of LongWord;
PBuffer32 = ^TBuffer32;
TBuffer8 = array[0..0] of Byte;
PBuffer8 = ^TBuffer8;
function IsZero(Buffer32: Pointer; BufferSize: Integer): Boolean;
var
Size32: Integer;
Buffer8: PBuffer8;
Buffer32: PBuffer32;
i: Integer;
begin
Result := False;
Buffer32 := Buffer;
Size32 := BufferSize shr 2;
for i := 0 to Size32-1 do
if Buffer32[i] <> 0 then // test 4 bytes at a time
Exit;
Buffer8 := Buffer;
for i := 0 to BufferSize - (Size32 shl 2) -1 do
if Buffer8[i] <> 0 then // test remaining 1,2, or 3 bytes
Exit;
Result := True;
end;
Regards,
Ross.
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi