Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove capture of EventId to reduce constant boxing #318

Closed
snakefoot opened this issue Aug 20, 2019 · 0 comments · Fixed by #319
Closed

Remove capture of EventId to reduce constant boxing #318

snakefoot opened this issue Aug 20, 2019 · 0 comments · Fixed by #319

Comments

@snakefoot
Copy link
Contributor

snakefoot commented Aug 20, 2019

There are the following lines (Where "EventId" is boxing):

var idIsZero = eventId.Id == 0;
eventInfo.Properties[eventIdPropertyNames.Item2] = idIsZero ? ZeroEventId : eventId.Id;
eventInfo.Properties[eventIdPropertyNames.Item3] = eventId.Name;
eventInfo.Properties["EventId"] = idIsZero && eventId.Name == null ? EmptyEventId : eventId;

I would like to change it to this instead to reduce allocation:

if (eventId.Id != 0)
   eventInfo.Properties[eventIdPropertyNames.Item2] = eventId.Id;
if (!string.IsNullOrEmpty(eventId.Name))
   eventInfo.Properties[eventIdPropertyNames.Item3] = eventId.Name;

Maybe have it as configuration setting, where the default is to reduce allocation.

@304NotModified 304NotModified self-assigned this Aug 20, 2019
@304NotModified 304NotModified added this to the 2.0 milestone Aug 30, 2019
@304NotModified 304NotModified removed their assignment Sep 21, 2019
@304NotModified 304NotModified changed the title Remove capture of EventId to reduce constant boxing Remove capture of EventId to reduce constant boxing (WIP) Sep 21, 2019
@304NotModified 304NotModified changed the title Remove capture of EventId to reduce constant boxing (WIP) Remove capture of EventId to reduce constant boxing Sep 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants