Line | |
---|
1 | unit UGenericShared;
|
---|
2 |
|
---|
3 | {$mode Delphi}{$H+}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils;
|
---|
9 |
|
---|
10 | function FastCompareMem(P1, P2: Pointer; Length: cardinal): Boolean; inline;
|
---|
11 | function FastCompareMem2(P1, P2: Pointer; Length: cardinal): Boolean; inline;
|
---|
12 |
|
---|
13 | implementation
|
---|
14 |
|
---|
15 | function FastCompareMem(P1, P2: Pointer; Length: cardinal): Boolean;
|
---|
16 | var
|
---|
17 | i: cardinal;
|
---|
18 | begin
|
---|
19 | Result:=True;
|
---|
20 | I:=0;
|
---|
21 | If (P1)<>(P2) then
|
---|
22 | While Result and (i<Length) do
|
---|
23 | begin
|
---|
24 | Result:=PByte(P1)^=PByte(P2)^;
|
---|
25 | Inc(I);
|
---|
26 | Inc(pchar(P1));
|
---|
27 | Inc(pchar(P2));
|
---|
28 | end;
|
---|
29 | end;
|
---|
30 |
|
---|
31 | function FastCompareMem2(P1, P2: Pointer; Length: cardinal): Boolean;
|
---|
32 | var
|
---|
33 | i: cardinal;
|
---|
34 | begin
|
---|
35 | Result:=True;
|
---|
36 | I:=0;
|
---|
37 | If (P1)<>(P2) then
|
---|
38 | While Result and (i<Length) do
|
---|
39 | begin
|
---|
40 | Result:=PByte(P1)^=PByte(P2)^;
|
---|
41 | Inc(I);
|
---|
42 | Inc(pchar(P1));
|
---|
43 | Inc(pchar(P2));
|
---|
44 | end;
|
---|
45 | end;
|
---|
46 |
|
---|
47 |
|
---|
48 | end.
|
---|
49 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.