Skip to content

Commit

Permalink
Merge pull request #16336 from tinchodias/SpeedUpEmptyAnnouncer
Browse files Browse the repository at this point in the history
Announcer: Return early if there isn't any subscriber
  • Loading branch information
MarcusDenker committed Apr 26, 2024
2 parents 1468266 + f95ea61 commit 707ebfb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/Announcements-Core/Announcer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,22 @@ Class {
Announcer >> announce: anAnnouncement [

^ self isSuspended
ifFalse: [
| announcement |
announcement := anAnnouncement asAnnouncement.

"If the user required to prevent the current announcement, we stop here."
(self preventedAnnouncements handlesAnnouncement: announcement) ifTrue: [ ^ self ].

registry ifNotNil: [ registry deliver: announcement ].
announcement ]
ifTrue: [ storedAnnouncements ifNotNil: [ storedAnnouncements add: anAnnouncement ] ]
ifFalse: [
| announcement |
announcement := anAnnouncement asAnnouncement.

"Stop if there isn't any subscriber"
registry isEmpty ifTrue: [ ^ announcement ].

"If the user required to prevent the current announcement, we stop here."
(self preventedAnnouncements handlesAnnouncement: announcement)
ifTrue: [ ^ announcement ].

registry deliver: announcement.
announcement ]
ifTrue: [
storedAnnouncements ifNotNil: [
storedAnnouncements add: anAnnouncement ] ]
]

{ #category : 'private' }
Expand Down
6 changes: 6 additions & 0 deletions src/Announcements-Core/SubscriptionRegistry.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ SubscriptionRegistry >> initialize [
self reset
]

{ #category : 'testing' }
SubscriptionRegistry >> isEmpty [

^ subscriptions isEmpty
]

{ #category : 'accessing' }
SubscriptionRegistry >> numberOfSubscriptions [

Expand Down

0 comments on commit 707ebfb

Please sign in to comment.