Skip to content

Avoid boxing context.Method #5687

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

Merged
merged 1 commit into from
Dec 27, 2018
Merged

Conversation

benaadams
Copy link
Member

@benaadams benaadams commented Dec 18, 2018

object.ReferenceEquals(context.Method, HttpMethods.Get) boxes context.Method as its an enum and will always return false.

As context.Method == HttpMethod.Post || context.Method == HttpMethod.Put are two enum compares rather than a string compare we don't really need to change the if to a context.Method != HttpMethod.Get and can just get rid of it.

@davidfowl
Copy link
Member

Just to show what this looks like before this change:

image

HttpMethod shows up as a per request allocation.

@pakrym
Copy link
Contributor

pakrym commented Dec 18, 2018

@davidfowl
Copy link
Member

We'll do that next 😄

@benaadams benaadams closed this Dec 18, 2018
@benaadams benaadams reopened this Dec 18, 2018
@davidfowl davidfowl closed this Dec 27, 2018
@davidfowl davidfowl reopened this Dec 27, 2018
@pakrym
Copy link
Contributor

pakrym commented Dec 27, 2018

Test failures are unrelated. Merging.

@pakrym pakrym merged commit 8be8e00 into dotnet:master Dec 27, 2018
@benaadams benaadams deleted the don't-box-method branch February 23, 2019 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants