Skip to content

Commit

Permalink
Avoid creating traversers for empty lists #29
Browse files Browse the repository at this point in the history
  • Loading branch information
bero committed Dec 7, 2024
1 parent 36f2ca1 commit b05dd6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Source/BoldLockRegions.pas
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,9 @@ procedure TBoldRegionLookup.AddRegionLookup(Regions: TBoldRegionLookup);
var
Region: TBoldRegion;
begin
for Region in Regions do
AddIfNotInLookup(Region);
if not Regions.IsEmpty then
for Region in Regions do
AddIfNotInLookup(Region);
end;

constructor TBoldRegionLookup.Create;
Expand Down
4 changes: 4 additions & 0 deletions Source/BoldOptimisticLockingSupport.pas
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ procedure TBoldOptimisticLockHandler.GetLockingValuesForRegions(Regions: TBoldRe
var
Traverser: TBoldIndexableListTraverser;
begin
if Regions.IsEmpty then
exit;
Traverser := Regions.CreateTraverser;
while Traverser.MoveNext do
begin
Expand Down Expand Up @@ -446,6 +448,8 @@ procedure TBoldOptimisticLockHandler.AddRegionsObjectsToEnclosure(
var
Traverser: TBoldIndexableListTraverser;
begin
if Regions.IsEmpty then
exit;
Traverser := Regions.CreateTraverser;
while Traverser.MoveNext do
begin
Expand Down

0 comments on commit b05dd6d

Please sign in to comment.