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
protocol P { | |
func foo() | |
func bar() | |
} | |
extension P { | |
func foo() { print("foo() from P") } | |
func bar() { print("bar() from P") } | |
} |
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
let info = mach_timebase_info_t.allocate(capacity: 1) | |
mach_timebase_info(info) | |
var avg: Double = 0 | |
let lock: UnsafeMutableRawPointer! | |
if #available(macOS 10.12, iOS 10.0, *), true { | |
let lock1 = os_unfair_lock_t.allocate(capacity: 1) | |
lock1.initialize(to: os_unfair_lock()) | |
lock = UnsafeMutableRawPointer(lock1) |
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
import XCTest | |
import ReactiveSwift | |
import Result | |
private func _measure(times: UInt64 = 2_000_000, label: String = #function, _ action: (() -> UInt64) -> Void) { | |
var result: UInt64 = 0 | |
var minResult: UInt64 = .max | |
for i in 0 ..< times { | |
var start: UInt64! |
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
import XCTest | |
import ReactiveSwift | |
import Result | |
private func _measure(times: UInt64 = 2_000_000, label: String = #function, _ action: (() -> UInt64) -> Void) { | |
var result: UInt64 = 0 | |
var minResult: UInt64 = .max | |
for i in 0 ..< times { | |
var start: UInt64! |
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
import XCTest | |
private func _measure(times: UInt64 = 2_000_000, label: String = #function, _ action: (() -> UInt64) -> Void) { | |
var result: UInt64 = 0 | |
var minResult: UInt64 = .max | |
for i in 0 ..< times { | |
var start: UInt64! | |
action { | |
start = mach_absolute_time() |
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
import XCTest | |
import ReactiveSwift | |
import Result | |
private func _measure(times: UInt64 = 2_000_000, label: String = #function, _ action: (() -> UInt64) -> Void) { | |
var result: UInt64 = 0 | |
var minResult: UInt64 = .max | |
for i in 0 ..< times { | |
var start: UInt64! |
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
class ManuallyFinishingOperation: BlockOperation { | |
override var isFinished: Bool { | |
return _isFinished && super.isFinished | |
} | |
var _isFinished: Bool = false { | |
willSet { willChangeValue(forKey: "isFinished") } | |
didSet { didChangeValue(forKey: "isFinished") } | |
} |
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
import XCTest | |
import ReactiveSwift | |
import Result | |
private func _measure(times: UInt64 = 2_000_000, label: String = #function, _ action: (() -> UInt64) -> Void) { | |
var result: UInt64 = 0 | |
var minResult: UInt64 = .max | |
for i in 0 ..< times { | |
var start: UInt64! |
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
import XCTest | |
import ReactiveSwift | |
import Result | |
class BagTests: XCTestCase { | |
func testCopying() { | |
var _bag = Bag<Int>() | |
_ = (0 ..< 32_768).map { _bag.insert($0) } | |
self.measure { |
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
// `Entity` protocol. | |
protocol Entity: Codeable { | |
var identifier: UInt { get } | |
} | |
protocol EntityIdentifer: Codeable { | |
var identifier: UInt { get } | |
} | |
struct Identifier<E: Entity>: EntityIdentifer { |
NewerOlder