Skip to content

Commit

Permalink
require ChannelOptions to be Equatable
Browse files Browse the repository at this point in the history
Motivation:

ChannelOptions should've always been Equatable and so far we've hacked
around them not being Equatable when we wanted to compare them.

Modifications:

make all ChannelOptions Equtable

Result:

- ChannelOption comparison actually works
- fixes apple#598
- make more ChannelOptions stuff inlinable to not regress allocations
  • Loading branch information
weissi committed Feb 21, 2019
1 parent 46ffd63 commit 84f0af1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Sources/NIO/ChannelOption.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ public struct SocketOption: ChannelOption, Equatable {
self.level = level
self.name = name
}

public static func == (lhs: SocketOption, rhs: SocketOption) -> Bool {
switch (lhs, rhs) {
case (.const(let lLevel, let lName), .const(let rLevel, let rName)):
return lLevel == rLevel && lName == rName
}
}
}

/// `AllocatorOption` allows to specify the `ByteBufferAllocator` to use.
Expand Down
1 change: 1 addition & 0 deletions docs/public-api-changes-NIO1-to-NIO2.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@
- change `ChannelPipeline.addHandler[s](_:first:)` to `ChannelPipeline.addHandler(_:postion:)` where `position` can be `.first`, `.last`, `.before(ChannelHandler)`, and `.after(ChannelHandler)`
- change `ChannelPipeline.addHandler(_:before:)` to `ChannelPipeline.addHandler(_:postion:)` where `position` can be `.first`, `.last`, `.before(ChannelHandler)`, and `.after(ChannelHandler)`
- change `ChannelPipeline.addHandler(_:after:)` to `ChannelPipeline.addHandler(_:postion:)` where `position` can be `.first`, `.last`, `.before(ChannelHandler)`, and `.after(ChannelHandler)`
- all `ChannelOption`s are now required to be `Equatable`

0 comments on commit 84f0af1

Please sign in to comment.