Skip to content

A delegate object is created for each IOptionsMonitor<T>.Get call #61086

@rayao

Description

@rayao

return _cache.GetOrAdd(name, () => _factory.Create(name));

It could be avoided if the delegate is a member, or simply Add a TryGetValue call before calling GetOrAdd.
The object allocation is much more expensive than the getting itself, when CurrentValue/Get is used in hot code path, the cost will be unexpected.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions