-
Notifications
You must be signed in to change notification settings - Fork 638
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
CircularBuffer: use vendored swift-collections/Deque instead #1792
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* Changes for SwiftNIO | ||
| - renamed NIODeque to NIONIODeque (to prevent future clashes) | ||
| - made (NIO)NIODeque internal (not public) | ||
|
|
||
| DO NOT CHANGE THESE FILES, THEY ARE VENDORED FROM Swift Collections. | ||
| */ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This source file is part of the Swift Collections open source project | ||
| // | ||
| // Copyright (c) 2021 Apple Inc. and the Swift project authors | ||
| // Licensed under Apache License v2.0 with Runtime Library Exception | ||
| // | ||
| // See https://swift.org/LICENSE.txt for license information | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| extension NIODeque: Encodable where Element: Encodable { | ||
| /// Encodes the elements of this deque into the given encoder in an unkeyed | ||
| /// container. | ||
| /// | ||
| /// This function throws an error if any values are invalid for the given | ||
| /// encoder's format. | ||
| /// | ||
| /// - Parameter encoder: The encoder to write data to. | ||
| /* was @inlinable */ | ||
| @usableFromInline internal /*was public */ func encode(to encoder: Encoder) throws { | ||
| var container = encoder.unkeyedContainer() | ||
| for element in self { | ||
| try container.encode(element) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| extension NIODeque: Decodable where Element: Decodable { | ||
| /// Creates a new deque by decoding from the given decoder. | ||
| /// | ||
| /// This initializer throws an error if reading from the decoder fails, or | ||
| /// if the data read is corrupted or otherwise invalid. | ||
| /// | ||
| /// - Parameter decoder: The decoder to read data from. | ||
| /* was @inlinable */ | ||
| @usableFromInline internal /*was public */ init(from decoder: Decoder) throws { | ||
| self.init() | ||
|
|
||
| var container = try decoder.unkeyedContainer() | ||
| if let count = container.count { | ||
| self.reserveCapacity(count) | ||
| } | ||
| while !container.isAtEnd { | ||
| let element = try container.decode(Element.self) | ||
| self.append(element) | ||
| } | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
Sources/NIO/VendoredDeque/Deque+CustomDebugStringConvertible.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* Changes for SwiftNIO | ||
| - renamed NIODeque to NIONIODeque (to prevent future clashes) | ||
| - made (NIO)NIODeque internal (not public) | ||
|
|
||
| DO NOT CHANGE THESE FILES, THEY ARE VENDORED FROM Swift Collections. | ||
| */ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This source file is part of the Swift Collections open source project | ||
| // | ||
| // Copyright (c) 2021 Apple Inc. and the Swift project authors | ||
| // Licensed under Apache License v2.0 with Runtime Library Exception | ||
| // | ||
| // See https://swift.org/LICENSE.txt for license information | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| extension NIODeque: CustomDebugStringConvertible { | ||
| /// A textual representation of this instance, suitable for debugging. | ||
| @usableFromInline internal /*was public */ var debugDescription: String { | ||
| var result = "NIODeque<\(Element.self)>([" | ||
| var first = true | ||
| for item in self { | ||
| if first { | ||
| first = false | ||
| } else { | ||
| result += ", " | ||
| } | ||
| debugPrint(item, terminator: "", to: &result) | ||
| } | ||
| result += "])" | ||
| return result | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /* Changes for SwiftNIO | ||
| - renamed NIODeque to NIONIODeque (to prevent future clashes) | ||
| - made (NIO)NIODeque internal (not public) | ||
|
|
||
| DO NOT CHANGE THESE FILES, THEY ARE VENDORED FROM Swift Collections. | ||
| */ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This source file is part of the Swift Collections open source project | ||
| // | ||
| // Copyright (c) 2021 Apple Inc. and the Swift project authors | ||
| // Licensed under Apache License v2.0 with Runtime Library Exception | ||
| // | ||
| // See https://swift.org/LICENSE.txt for license information | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| extension NIODeque: CustomReflectable { | ||
| /// The custom mirror for this instance. | ||
| @usableFromInline internal /*was public */ var customMirror: Mirror { | ||
| Mirror(self, unlabeledChildren: self, displayStyle: .collection) | ||
| } | ||
| } | ||
34 changes: 34 additions & 0 deletions
34
Sources/NIO/VendoredDeque/Deque+CustomStringConvertible.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* Changes for SwiftNIO | ||
| - renamed NIODeque to NIONIODeque (to prevent future clashes) | ||
| - made (NIO)NIODeque internal (not public) | ||
|
|
||
| DO NOT CHANGE THESE FILES, THEY ARE VENDORED FROM Swift Collections. | ||
| */ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This source file is part of the Swift Collections open source project | ||
| // | ||
| // Copyright (c) 2021 Apple Inc. and the Swift project authors | ||
| // Licensed under Apache License v2.0 with Runtime Library Exception | ||
| // | ||
| // See https://swift.org/LICENSE.txt for license information | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| extension NIODeque: CustomStringConvertible { | ||
| /// A textual representation of this instance. | ||
| @usableFromInline internal /*was public */ var description: String { | ||
| var result = "[" | ||
| var first = true | ||
| for item in self { | ||
| if first { | ||
| first = false | ||
| } else { | ||
| result += ", " | ||
| } | ||
| print(item, terminator: "", to: &result) | ||
| } | ||
| result += "]" | ||
| return result | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* Changes for SwiftNIO | ||
| - renamed NIODeque to NIONIODeque (to prevent future clashes) | ||
| - made (NIO)NIODeque internal (not public) | ||
|
|
||
| DO NOT CHANGE THESE FILES, THEY ARE VENDORED FROM Swift Collections. | ||
| */ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This source file is part of the Swift Collections open source project | ||
| // | ||
| // Copyright (c) 2021 Apple Inc. and the Swift project authors | ||
| // Licensed under Apache License v2.0 with Runtime Library Exception | ||
| // | ||
| // See https://swift.org/LICENSE.txt for license information | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| extension NIODeque: Equatable where Element: Equatable { | ||
| /// Returns a Boolean value indicating whether two values are equal. Two | ||
| /// deques are considered equal if they contain the same elements in the same | ||
| /// order. | ||
| /// | ||
| /// - Complexity: O(`min(left.count, right.count)`) | ||
| /* was @inlinable */ | ||
| @usableFromInline internal /*was public */ static func ==(left: Self, right: Self) -> Bool { | ||
| return left.elementsEqual(right) | ||
| } | ||
| } |
33 changes: 33 additions & 0 deletions
33
Sources/NIO/VendoredDeque/Deque+ExpressibleByArrayLiteral.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* Changes for SwiftNIO | ||
| - renamed NIODeque to NIONIODeque (to prevent future clashes) | ||
| - made (NIO)NIODeque internal (not public) | ||
|
|
||
| DO NOT CHANGE THESE FILES, THEY ARE VENDORED FROM Swift Collections. | ||
| */ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This source file is part of the Swift Collections open source project | ||
| // | ||
| // Copyright (c) 2021 Apple Inc. and the Swift project authors | ||
| // Licensed under Apache License v2.0 with Runtime Library Exception | ||
| // | ||
| // See https://swift.org/LICENSE.txt for license information | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| extension NIODeque: ExpressibleByArrayLiteral { | ||
| /// Creates a new deque from the contents of an array literal. | ||
| /// | ||
| /// Do not call this initializer directly. It is used by the compiler when | ||
| /// you use an array literal. Instead, create a new set using an array | ||
| /// literal as its value by enclosing a comma-separated list of values in | ||
| /// square brackets. You can use an array literal anywhere a set is expected | ||
| /// by the type context. | ||
| /// | ||
| /// - Parameter elements: A variadic list of elements of the new set. | ||
| /* was @inlinable */ | ||
| @inline(__always) | ||
| @usableFromInline internal /*was public */ init(arrayLiteral elements: Element...) { | ||
| self.init(elements) | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Something here is prefixing NIO again.