-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathuinlineblock1.pas
More file actions
39 lines (30 loc) · 804 Bytes
/
Copy pathuinlineblock1.pas
File metadata and controls
39 lines (30 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
unit uinlineblock1;
{$mode delphi}
{$inline on}
interface
type
TShrinkProc = function(ARequired: LongInt): LongInt;
TFallback = object
class function Shrink(const ARequired, ACurrent: LongInt): LongInt; static; inline;
end;
TWrapper = object
Callback: TShrinkProc;
Fallback: TFallback;
function Shrink(const ARequired, ACurrent: LongInt): LongInt; inline;
end;
implementation
class function TFallback.Shrink(const ARequired, ACurrent: LongInt): LongInt;
begin
if Int64(ARequired) * 4 < ACurrent then
Result := ARequired * 2
else
Result := -1;
end;
function TWrapper.Shrink(const ARequired, ACurrent: LongInt): LongInt;
begin
if Assigned(Callback) then
Result := Callback(ARequired)
else
Result := Fallback.Shrink(ARequired, ACurrent);
end;
end.