Skip to content

Make GetFinalTransferCoding "safe" #21202

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 2 commits into from
Apr 28, 2020

Conversation

benaadams
Copy link
Member

To @blowdart with ❤

Contributes to #4720

const ulong lowerCaseULong = 0x0020_0020_0020_0020;
const uint lowerCaseUInt = 0x0020_0020;

const ulong hunkChars = 0x006b_006e_0075_0068; // 4 chars "hunk"
Copy link
Member

Choose a reason for hiding this comment

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

These are "funny" names 😉

What about chunkRemainderChars or that like, so that it's not that obscure to read if you're not in the mental context of the method?

I thought the same in #21004

Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed a little


var byteValue = MemoryMarshal.AsBytes(value);

if ((c | lowerCaseChar) == 'c' &&
Copy link
Member

@gfoidl gfoidl Apr 25, 2020

Choose a reason for hiding this comment

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

I see this (good) pattern repeated several times (also in the other PRs).

Maybe this can be refactored with the struct-trick (I'm sure you get the idea)

But I don't know if this is a win code-wise. The constants (see comment above) could be wrapped in more obvious names that way and the logic re-used.
Together with a potential SIMD-approach (if it's worth it) the code would get cleaner.

Perf-wise it should result in the same.

@benaadams benaadams force-pushed the GetFinalTransferCoding branch from b78ca3d to 480fe06 Compare April 25, 2020 19:20
@benaadams benaadams force-pushed the GetFinalTransferCoding branch from 480fe06 to 67588d5 Compare April 25, 2020 19:22
@halter73 halter73 merged commit 5fc0672 into dotnet:master Apr 28, 2020
@benaadams benaadams deleted the GetFinalTransferCoding branch May 27, 2020 06:47
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants