Skip to content

Commit

Permalink
Performance impact fix (#1661)
Browse files Browse the repository at this point in the history
  • Loading branch information
Int32Overflow authored Jan 28, 2023
1 parent c90ba7e commit 0234918
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Source/MQTTnet/Server/Internal/MqttClientSubscriptionsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,23 +403,23 @@ static void FilterRetainedApplicationMessages(
CreateSubscriptionResult createSubscriptionResult,
SubscribeResult subscribeResult)
{
for (var index = retainedMessages.Count - 1; index >= 0; index--)
if (createSubscriptionResult.Subscription.RetainHandling == MqttRetainHandling.DoNotSendOnSubscribe)
{
var retainedMessage = retainedMessages[index];
if (retainedMessage == null)
{
continue;
// This is a MQTT V5+ feature.
return;
}

if (createSubscriptionResult.Subscription.RetainHandling == MqttRetainHandling.DoNotSendOnSubscribe)
if (createSubscriptionResult.Subscription.RetainHandling == MqttRetainHandling.SendAtSubscribeIfNewSubscriptionOnly && !createSubscriptionResult.IsNewSubscription)
{
// This is a MQTT V5+ feature.
continue;
return;
}

if (createSubscriptionResult.Subscription.RetainHandling == MqttRetainHandling.SendAtSubscribeIfNewSubscriptionOnly && !createSubscriptionResult.IsNewSubscription)
for (var index = retainedMessages.Count - 1; index >= 0; index--)
{
var retainedMessage = retainedMessages[index];
if (retainedMessage == null)
{
// This is a MQTT V5+ feature.
continue;
}

Expand Down

0 comments on commit 0234918

Please sign in to comment.