Skip to content

Commit

Permalink
Removed conditonal, code now integrated. #20
Browse files Browse the repository at this point in the history
  • Loading branch information
bero committed Dec 6, 2024
1 parent 5e575f8 commit cd86ed6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 64 deletions.
3 changes: 0 additions & 3 deletions Source/Bold.inc
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ Illegal symbol combination
// Use OXML instead of MSXML for XML operations (faster and can handle larger XML)
{.$DEFINE OXML}

// Faster Display Queue - Simplified handling of (Most)Prioritized and less iteration of Display List
{$DEFINE BoldQueue_Optimization}

// When fetching an object which class list is loaded then search there instead of going to db.
{$DEFINE FetchFromClassList}

Expand Down
62 changes: 1 addition & 61 deletions Source/BoldQueue.pas
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ interface
{ Queueable }
befIsInDisplayList = BoldElementFlag0;
befStronglyDependedOfPrioritized = BoldElementFlag1;
{$IFDEF BoldQueue_Optimization}
befToBeRemovedFromDisplayList = BoldElementFlag2;
{$ENDIF}
{ Follower }
befFollowerSelected = BoldElementFlag3;

Expand All @@ -42,9 +40,7 @@ TBoldQueueable = class(TBoldFlaggedObject)
function AfterInPriority(Queueable: TBoldQueueable): Boolean;
procedure Display; virtual; abstract;
function StronglyPrioritizedSibbling(Queueable: TBoldQueueable): Boolean;
{$IFDEF BoldQueue_Optimization}
property ToBeRemovedFromDisplayList: Boolean index befToBeRemovedFromDisplayList read GetElementFlag write SetElementFlag;
{$ENDIF}
class function DisplayOne: Boolean;
function GetDebugInfo: string; override;
public
Expand Down Expand Up @@ -80,9 +76,7 @@ TBoldQueue = class(TBoldMemoryManagedObject)
fPostDisplayQueue: TBoldEventQueue;
fDisplayList: TList;
fApplyList: TList;
{$IFDEF BoldQueue_Optimization}
fDisplayListIndex: Integer;
{$ENDIF}
function GetApplyCount: integer;
function GetDisplayCount: integer;
function GetPostDisplayCount: integer;
Expand Down Expand Up @@ -169,11 +163,7 @@ destructor TBoldQueueable.Destroy;
begin
RemoveFromApplyList;
RemoveFromDisplayList(true);
{$IFDEF BoldQueue_Optimization}
Assert(not (IsInDisplayList or ToBeRemovedFromDisplayList));
{$ELSE}
Assert(not IsInDisplayList);
{$ENDIF}
inherited Destroy;
end;

Expand Down Expand Up @@ -201,23 +191,17 @@ procedure TBoldQueueable.AddToDisplayList;
if not BoldQueueFinalized then
begin
Assert(not IsInDisplayList);
{$IFDEF BoldQueue_Optimization}
if ToBeRemovedFromDisplayList then
ToBeRemovedFromDisplayList := false
else
{$ENDIF}
BoldInstalledQueue.AddToDisplayList(self);
SetElementflag(befIsInDisplayList, True);
end;
end;

procedure TBoldQueueable.RemoveFromDisplayList(ADestroying: boolean);
begin
{$IFDEF BoldQueue_Optimization}
if not (BoldQueueFinalized) and (IsInDisplayList or ToBeRemovedFromDisplayList) then
{$ELSE}
if not BoldQueueFinalized and IsInDisplayList then
{$ENDIF}
begin
BoldInstalledQueue.RemoveFromDisplayList(self, ADestroying);
SetElementflag(befIsInDisplayList, False);
Expand Down Expand Up @@ -245,9 +229,7 @@ function TBoldQueueable.MostPrioritizedQueuable: TBoldQueueable;
begin
Queueable := fDisplayList[i];
if assigned(Queueable) and
{$IFDEF BoldQueue_Optimization}
Queueable.IsInDisplayList and
{$ENDIF}
Queueable.AfterInPriority(PrioritizedQueuable) and
not StronglyPrioritizedSibbling(Queueable) and
not Queueable.AfterInPriority(self) then
Expand Down Expand Up @@ -456,7 +438,7 @@ function TBoldQueue.DisplayAll: Boolean;
end;

function TBoldQueue.DisplayOne: Boolean;
{$IFDEF BoldQueue_Optimization}

var
Queueable, vPrioritizedQueuable: TBoldQueueable;
begin
Expand Down Expand Up @@ -511,44 +493,6 @@ function TBoldQueue.DisplayOne: Boolean;
end;
end;
end;
{$ELSE}
var
Index: Integer;
ExchangeWith,
Queueable: TBoldQueueable;
begin
if fIsDisplaying or (fDisplayList.Count = 0) then
result := false
else
begin
fIsDisplaying := true;
try
Queueable := nil;
while (fDisplayList.Count>0) and (fDisplayList.Last=nil) do
fDisplayList.Count := fDisplayList.Count - 1;
Result := fDisplayList.Count>0;
if Result then
begin
try
ExchangeWith := TBoldQueueable(fDisplayList.Last).MostPrioritizedQueuable;
if Assigned(ExchangeWith) then
begin
Index := fDisplayList.IndexOf(ExchangeWith);
if Index <> -1 then
fDisplayList.Exchange(Index, fDisplayList.Count - 1);
end;
Queueable := TBoldQueueable(fDisplayList.Last);
Queueable.Display;
except
raise; // patch this used to directly call Application.HandleException(Queueable);
end;
end;
finally
fIsDisplaying := false;
end;
end;
end;
{$ENDIF}

function TBoldQueueable.AfterInPriority(Queueable: TBoldQueueable): Boolean;
begin
Expand Down Expand Up @@ -626,7 +570,6 @@ procedure TBoldQueue.RemoveFromDisplayList(Queueable: TBoldQueueable; ADestroyin
index: integer;
begin
// Log('R:'+Queueable.ClassName);
{$IFDEF BoldQueue_Optimization}
if (fDisplayList.Last = Queueable) then
begin
Queueable.ToBeRemovedFromDisplayList := false;
Expand All @@ -638,15 +581,12 @@ procedure TBoldQueue.RemoveFromDisplayList(Queueable: TBoldQueueable; ADestroyin
Queueable.ToBeRemovedFromDisplayList := true;
exit;
end;
{$ENDIF}
Index := fDisplayList.Count - 1;
while (Index >=0 ) and (fDisplayList.List[Index] <> Queueable) do
Dec(Index);
if Index > -1 then
begin
{$IFDEF BoldQueue_Optimization}
Queueable.ToBeRemovedFromDisplayList := false;
{$ENDIF}
if Index = fdisplayList.Count - 1 then
fDisplayList.Count := fDisplayList.Count - 1
else
Expand Down

0 comments on commit cd86ed6

Please sign in to comment.