-
Notifications
You must be signed in to change notification settings - Fork 409
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
More strongly-type multiple fields and return types #2242
Conversation
Some of these, like JsonClaimSet._jsonClaims, help to avoid allocation by ensuring that when the collection is enumerated, we're using its struct enumerator. In other cases, like with CreateClaimFromObject, we reduce the overhead of calls to the object. And other cases are just good hygiene.
19c1c7a
to
652de25
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @stephentoub
@@ -43,16 +43,16 @@ internal IList<Claim> Claims(string issuer) | |||
return _claims; | |||
} | |||
|
|||
internal IList<Claim> CreateClaims(string issuer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stephentoub Notice you changed all Interfaces to Concrete Subtypes. Just curious what is the benefit or advantage of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of the advantages were noted in the PR description.
For example, if you have:
IList<T> list = ...;
foreach (T item in list) { ... }
that allocates an IEnumerator<T>
object. If you instead have:
List<T> list = ...;
foreach (T item in list) { ... }
it doesn't, instead using the List<T>.Enumerator
struct for enumeration.
But even just simple accesses, e.g.
IList<T> list = ...;
return list[2];
That involves interface dispatch, which is not only slower than a regular method invocation:
List<T> list = ...;
return list[2];
but without a technology like dynamic PGO, it can't be inlined.
Included in preview4 release |
Some of these, like JsonClaimSet._jsonClaims, help to avoid allocation by ensuring that when the collection is enumerated, we're using its struct enumerator. In other cases, like with CreateClaimFromObject, we reduce the overhead of calls to the object. And other cases are just good hygiene.
Some of these, like JsonClaimSet._jsonClaims, help to avoid allocation by ensuring that when the collection is enumerated, we're using its struct enumerator. In other cases, like with CreateClaimFromObject, we reduce the overhead of calls to the object. And other cases are just good hygiene.
Some of these, like JsonClaimSet._jsonClaims, help to avoid allocation by ensuring that when the collection is enumerated, we're using its struct enumerator. In other cases, like with CreateClaimFromObject, we reduce the overhead of calls to the object. And other cases are just good hygiene.