Skip to content
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

Make HPACKHeaders hashable. #344

Merged
merged 4 commits into from
May 4, 2022
Merged

Conversation

Lukasa
Copy link
Contributor

@Lukasa Lukasa commented May 4, 2022

Motivation:

HPACKHeaders is equatable, and it rarely makes sense to have a type that
is equatable but not hashable. The definition of equatability is pretty
limited here (see #342) but we can define a definition of hashability
consistent with it.

Modifications:

  • Make HPACKHeaders hashable.

Result:

People can store HPACKHeaders in Sets

Motivation:

HPACKHeaders is equatable, and it rarely makes sense to have a type that
is equatable but not hashable. The definition of equatability is pretty
limited here (see apple#342) but we can define a definition of hashability
consistent with it.

Modifications:

- Make HPACKHeaders hashable.

Result:

People can store HPACKHeaders in Sets
@Lukasa Lukasa added the semver/minor Adds new public API. label May 4, 2022
Copy link
Contributor

@Davidde94 Davidde94 left a comment

Choose a reason for hiding this comment

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

Minor question, otherwise looks good

@@ -394,6 +394,9 @@ extension HPACKHeaders: CustomStringConvertible {
}
}

// NOTE: This is a bad definition of equatable and hashable. In particular, both order and
// indexability are ignored. We're sort of stuck with this behaviour now and cannot change it,
// but in the next major version we should strongly consider revising it.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we link a GH issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I think this comment is just unnecessarily aggressive.

Sources/NIOHPACK/HPACKHeader.swift Outdated Show resolved Hide resolved
Copy link
Member

@dnadoba dnadoba left a comment

Choose a reason for hiding this comment

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

One perf and one question, otherwise LGTM

Sources/NIOHPACK/HPACKHeader.swift Show resolved Hide resolved
Sources/NIOHPACK/HPACKHeader.swift Outdated Show resolved Hide resolved
Co-authored-by: David Nadoba <dnadoba@gmail.com>
@Lukasa Lukasa enabled auto-merge (squash) May 4, 2022 15:34
@Lukasa Lukasa merged commit c28d13d into apple:main May 4, 2022
@Lukasa Lukasa deleted the cb-hpack-headers-hashable branch May 4, 2022 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants