Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

SqlClient: Avoid a delegate allocation on each call #7471

Merged
merged 1 commit into from
Apr 4, 2016

Conversation

justinvp
Copy link
Contributor

@justinvp justinvp commented Apr 3, 2016

Allow the compiler to lazily allocate and cache the Func delegate instead of allocating a new delegate on each call to GetDetailsForLcid.

@@ -32,7 +32,7 @@ static Locale()
{
throw ADP.ArgumentOutOfRange("lcid");
}
return s_cachedEncodings.GetOrAdd(lcid, GetDetailsInternal);
return s_cachedEncodings.GetOrAdd(lcid, id => GetDetailsInternal(id));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put a comment here to nobody "fixes it". TBH, the compiler should just fix this bug. @stephentoub reported it like 2 years ago...

/cc @jaredpar

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bug is when the compiler behaves counter to the design. The compiler is behaving as designed here so not a bug.

@stephentoub
Copy link
Member

LGTM

cc: @saurabh500

@saurabh500 saurabh500 merged commit 5184919 into dotnet:master Apr 4, 2016
@justinvp justinvp deleted the sqlclient_locale branch April 4, 2016 17:37
@karelz karelz modified the milestone: 1.0.0-rtm Dec 3, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
SqlClient: Avoid a delegate allocation on each call

Commit migrated from dotnet/corefx@5184919
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants