Skip to content

Commit

Permalink
Remove unnecessary null checks (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
gobradovic authored Sep 20, 2024
1 parent 2073037 commit 6a3e4c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ public void OneWayMessage(ServiceRemotingMessageHeaders serviceMessageHeaders, b
return;
}

if ((this.eventIdToDispatchersMap == null) ||
(!this.eventIdToDispatchersMap.TryGetValue(actorHeaders.InterfaceId, out var eventDispatcher)))
if (!this.eventIdToDispatchersMap.TryGetValue(actorHeaders.InterfaceId, out var eventDispatcher))
{
return;
}
Expand Down Expand Up @@ -110,13 +109,10 @@ public bool TryUnregisterSubscriber(ActorId actorId, Type eventInterfaceType, ob

private int GetAndEnsureEventId(Type eventInterfaceType)
{
if (this.eventIdToDispatchersMap != null)
var eventId = IdUtil.ComputeId(eventInterfaceType);
if (this.eventIdToDispatchersMap.ContainsKey(eventId))
{
var eventId = IdUtil.ComputeId(eventInterfaceType);
if (this.eventIdToDispatchersMap.ContainsKey(eventId))
{
return eventId;
}
return eventId;
}

throw new ArgumentException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public void HandleOneWayMessage(IServiceRemotingRequestMessage requestMessage)
{
var actorHeaders = (IActorRemotingMessageHeaders)requestMessage.GetHeader();

if ((this.eventIdToDispatchersMap == null) ||
(!this.eventIdToDispatchersMap.TryGetValue(actorHeaders.InterfaceId, out var eventDispatcher)))
if (!this.eventIdToDispatchersMap.TryGetValue(actorHeaders.InterfaceId, out var eventDispatcher))
{
return;
}
Expand Down Expand Up @@ -101,13 +100,10 @@ public bool TryUnregisterSubscriber(ActorId actorId, Type eventInterfaceType, ob

private int GetAndEnsureEventId(Type eventInterfaceType)
{
if (this.eventIdToDispatchersMap != null)
var eventId = IdUtil.ComputeIdWithCRC(eventInterfaceType);
if (this.eventIdToDispatchersMap.ContainsKey(eventId))
{
var eventId = IdUtil.ComputeIdWithCRC(eventInterfaceType);
if (this.eventIdToDispatchersMap.ContainsKey(eventId))
{
return eventId;
}
return eventId;
}

throw new ArgumentException();
Expand Down

0 comments on commit 6a3e4c3

Please sign in to comment.