I hereby claim:
- I am danappelxx on github.
- I am dannn (https://keybase.io/dannn) on keybase.
- I have a public key ASCT9QNqsziUWVm9U_uFCxpgp69kMqdq6B9D2U0AGVm8vwo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| public struct ThreadedFileResponder: Responder { | |
| let path: String | |
| let headers : Headers | |
| public init(path: String, headers: Headers = [:]) { | |
| self.path = path | |
| self.headers = headers | |
| } | |
| public func respond(to request: Request) throws -> Response { | |
| if request.method != .get { |
| // 2.2 (xcode 7.3), built with optimizations | |
| final class ArrayPerfTests: XCTestCase { | |
| let source = 0..<300_000 | |
| // otherwise, compiler would be able to optimize these loops by inlining. | |
| var map: (Int) -> String = { i in "\(i)" } | |
| // 118 ms (15% STDEV) | |
| func testRepeatedValue() { | |
| measureBlock { | |
| var array = Array(count: self.source.count, repeatedValue: "") |
| indirect enum Query { | |
| case equal(field: String, value: String) | |
| case notEqual(field: String, value: String) | |
| case not(query: Query) | |
| case or(first: Query, second: Query) | |
| case and(first: Query, second: Query) | |
| } | |
| func &&(lhs: Query, rhs: Query) -> Query { |
| notifications: | |
| slack: zewo:VjyVCCQvTOw9yrbzQysZezD1 | |
| os: | |
| - linux | |
| - osx | |
| language: generic | |
| sudo: required | |
| dist: trusty | |
| osx_image: xcode8 | |
| install: |
This proposal introduces a new keyword that can be applied to enums which allows new cases to be introduced in extensions.
| enum Heap<Key: Comparable> { | |
| case empty(key: Key) | |
| indirect case halfFull(key: Key, left: Heap<Key>) | |
| indirect case full(key: Key, left: Heap<Key>, right: Heap<Key>) | |
| } | |
| extension Heap { | |
| var isFull: Bool { | |
| if case .full(key: _, left: _, right: _) = self { | |
| return true |
| protocol Event {} | |
| protocol ErasedListener { | |
| func dispatchIfMatches(event: Event) | |
| } | |
| struct Listener<T: Event>: ErasedListener { | |
| let dispatch: T -> Void | |
| func dispatchIfMatches(event: Event) { | |
| (event as? T).flatMap(dispatch) |
| let length = 10 | |
| let ptr = UnsafeMutablePointer<UInt8>(allocatingCapacity: length) | |
| defer { ptr.deallocateCapacity(length) } | |
| for i in 0..<length { | |
| ptr.advanced(by: i).pointee = UInt8(i) | |
| } | |
| let buffer = UnsafeMutableBufferPointer(start: ptr, count: length) |
| // For evaluation purposes | |
| indirect enum Token: CustomStringConvertible { | |
| case Value(Int) | |
| case Add(Token, Token) | |
| case Subtract(Token, Token) | |
| case Multiply(Token, Token) | |
| case Divide(Token, Token) | |
| var description: String { | |
| switch self { |