Skip to content

Reduce List<object> allocations by passing the initial array #43989

@theolivenbaum

Description

@theolivenbaum

Not sure if this is the right repository, or if still relevant as I could not find the source code of EventSource here.

Some minor improvement I noticed while benchmarking allocations on our code, I think could be traced to the call to Add on the list in this line

image

    List<object> arg = new List<object>();
    arg.Add(msg);

could be changed to:

    List<object> arg = new List<object>(new []{ msg });

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions