mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 13:20:18 +02:00
Merge branch 'LCL/ControlsProc' into 'main'
LCL: Minor cleanup and optimization of functions in "controlsproc.inc" See merge request freepascal.org/lazarus/lazarus!328
This commit is contained in:
commit
8f1ebd08c0
@ -8,107 +8,53 @@
|
|||||||
for details about the license.
|
for details about the license.
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
}
|
}
|
||||||
procedure ListAdd(var List : TList; Item: Pointer);
|
procedure ListAdd(var List : TFPList; Item: Pointer); inline;
|
||||||
begin
|
|
||||||
if List = nil then
|
|
||||||
List := TList.Create;
|
|
||||||
List.Add(Item);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure ListInsert(var List : TList; Index : Longint; Item: Pointer);
|
|
||||||
begin
|
|
||||||
if List = nil then
|
|
||||||
List := TList.Create;
|
|
||||||
List.Insert(Index, Item);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function ListIndexOf(var List : TList; Item: Pointer) : Longint;
|
|
||||||
begin
|
|
||||||
Result := -1;
|
|
||||||
if List <> nil then
|
|
||||||
Result := List.IndexOf(Item);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function ListCount(List : TList) : Longint;
|
|
||||||
begin
|
|
||||||
Result := 0;
|
|
||||||
if List <> nil then
|
|
||||||
Result := List.Count;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure ListRemove(var List : TList; Item: Pointer);
|
|
||||||
begin
|
|
||||||
if List = nil then
|
|
||||||
Exit;
|
|
||||||
List.Remove(Item);
|
|
||||||
if List.Count = 0 then
|
|
||||||
begin
|
|
||||||
List.Free;
|
|
||||||
List := nil;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure ListDelete(var List : TList; Index: integer);
|
|
||||||
begin
|
|
||||||
if List = nil then
|
|
||||||
Exit;
|
|
||||||
List.Delete(Index);
|
|
||||||
if List.Count = 0 then
|
|
||||||
begin
|
|
||||||
List.Free;
|
|
||||||
List := nil;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure ListAdd(var List : TFPList; Item: Pointer);
|
|
||||||
begin
|
begin
|
||||||
if List = nil then
|
if List = nil then
|
||||||
List := TFPList.Create;
|
List := TFPList.Create;
|
||||||
List.Add(Item);
|
List.Add(Item);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure ListInsert(var List : TFPList; Index : Longint; Item: Pointer);
|
procedure ListInsert(var List : TFPList; Index : Longint; Item: Pointer); inline;
|
||||||
begin
|
begin
|
||||||
if List = nil then
|
if List = nil then
|
||||||
List := TFPList.Create;
|
List := TFPList.Create;
|
||||||
List.Insert(Index, Item);
|
List.Insert(Index, Item);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ListIndexOf(var List : TFPList; Item: Pointer) : Longint;
|
function ListIndexOf(var List : TFPList; Item: Pointer) : Longint; inline;
|
||||||
begin
|
begin
|
||||||
|
if assigned(List) then
|
||||||
|
Result := List.IndexOf(Item)
|
||||||
|
else
|
||||||
Result := -1;
|
Result := -1;
|
||||||
if List <> nil then
|
|
||||||
Result := List.IndexOf(Item);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ListCount(List : TFPList) : Longint;
|
function ListCount(List : TFPList) : Longint; inline;
|
||||||
begin
|
begin
|
||||||
|
if assigned(List) then
|
||||||
|
Result := List.Count
|
||||||
|
else
|
||||||
Result := 0;
|
Result := 0;
|
||||||
if List <> nil then
|
|
||||||
Result := List.Count;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure ListRemove(var List : TFPList; Item: Pointer);
|
procedure ListRemove(var List : TFPList; Item: Pointer); inline;
|
||||||
begin
|
begin
|
||||||
if List = nil then
|
if assigned(List) then
|
||||||
Exit;
|
begin
|
||||||
List.Remove(Item);
|
List.Remove(Item);
|
||||||
if List.Count = 0 then
|
if List.Count = 0 then
|
||||||
begin
|
FreeAndNil(List);
|
||||||
List.Free;
|
|
||||||
List := nil;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure ListDelete(var List : TFPList; Index: integer);
|
procedure ListDelete(var List : TFPList; Index: integer); inline;
|
||||||
begin
|
begin
|
||||||
if List = nil then
|
if assigned(List) then
|
||||||
Exit;
|
begin
|
||||||
List.Delete(Index);
|
List.Delete(Index);
|
||||||
if List.Count = 0 then
|
if List.Count = 0 then
|
||||||
begin
|
FreeAndNil(List);
|
||||||
List.Free;
|
|
||||||
List := nil;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user