mathpaquette / IQFeed.CSharpApiClient

IQFeed.CSharpApiClient is fastest and the most well-designed C# DTN IQFeed socket API connector available
MIT License
120 stars 43 forks source link

[MessageHandlers] Skipping Parse if related event is null #26

Closed Nucs closed 5 years ago

Nucs commented 6 years ago

Looking at Level1MessageHandler, every message that comes in is first parsed and only then it's related event is checked if it there is any delegates registered to it. Skipping the parsing will actually improve performance on heavy applications. note: this might be relevant to all message handlers.

Example for a fix:

    private void ProcessUpdateMessage(string msg)
    {
      Action<UpdateSummaryMessage> update = this.Update; //copy locally for multithreading purposes.
      if (update == null)
        return;
      update(UpdateSummaryMessage.Parse(msg));
    }

@mathpaquette, Let me know if you want a PR.

mathpaquette commented 5 years ago

Dont see really any valid use cases. I mean, the network will be even a bigger loss than this simple parsing thing. I should unwatch symbols when no one is using the data itself.

Nucs commented 5 years ago

You don't bake a cake if no one is hungry. You don't parse the message if no one will receive the update through the event.