Using Swift.Any
can be expensive.
benchmarking the following code
let n = 1_000_000
let intArray = Array(repeating: 1, count: n)
let anyArray = Array(repeating: 1 as Any, count: n)
let intTime = measure {
// JSONCore Extension | |
extension JSON { | |
func cast<T>() throws -> T { | |
guard let value: T = value as? T else { throw JSONConvertError.BadCast } | |
return value | |
} | |
/// Returns the content matching the type of its destination |
/// Generates 32 Psuedo Random bits in a reproducible way using a (PCG)[http://www.pcg-random.org/] RNG | |
struct PCGRand32 { | |
var state: Int64 | |
var inc: Int64 | |
mutating func rand() -> UInt32 { | |
let oldState = state | |
//Advance internal state | |
state = oldState &* 6364136223846793005 &+ (inc | 1) | |
// Calculate output function (XSH RR), uses old state for max ILP |
// | |
// OrderedDictionary.swift | |
// JSON | |
// | |
// Created by Ethan Jackwitz on 5/26/16. | |
// | |
public struct OrderedDictionary<Key: Hashable, Value> { | |
public typealias Element = (Key, Value) |
import PackageDescription | |
extension Version { | |
static let min: Version = Version(0, 0, 0) | |
static let max: Version = Version(.max, .max, .max) | |
static let any: Range<Version> = (Version.min..<Version.max) | |
} |
import CSDL2 | |
extension SDL { | |
public struct Error: ErrorProtocol { | |
public var message: String | |
public static var last: Error { | |
defer { SDL_ClearError() } |
cmd: "$(pwd)/build.sh" | |
name: "Build script" | |
sh: true, | |
errorMatch: | |
- "(?<file>[\\/0-9a-zA-Z\\._]+):(?<line>\\d+):(?<col>\\d+): error: (?<message>.+)" | |
warningMatch: | |
- "(?<file>[\\/0-9a-zA-Z\\._]+):(?<line>\\d+):(?<col>\\d+): warning: (?<message>.+)" | |
targets: | |
"Run Script": | |
sh: true |
Using Swift.Any
can be expensive.
benchmarking the following code
let n = 1_000_000
let intArray = Array(repeating: 1, count: n)
let anyArray = Array(repeating: 1 as Any, count: n)
let intTime = measure {
# Simple | |
# https://github.com/sotayamashita/simple | |
# | |
# MIT © Sota Yamashita | |
function __git_upstream_configured | |
git rev-parse --abbrev-ref @"{u}" > /dev/null 2>&1 | |
end | |
function __print_color |
public struct Key { | |
private let rawValue: UInt8 | |
private init(_ rawValue: UInt8) { | |
self.rawValue = rawValue | |
} | |
public let somePublicCase = Key(0) | |
private let somePrivateCase = Key(1) | |
private let anotherPrivateCase = Key(2) |
[ | |
{ "name": "bug", "color": "#e34424" }, | |
{ "name": "feature", "color": "#6cc644" }, | |
{ "name": "ready", "color": "#EAC04B" }, | |
{ "name": "in progress", "color": "#56d1f3" }, | |
{ "name": "on hold", "color": "#7d59c3" }, | |
{ "name": "regression", "color": "#fe9a00" }, | |
{ "name": "discussion", "color": "#7d59c3" }, | |
{ "name": "weight: 1", "color": "#ededed" }, | |
{ "name": "weight: 2", "color": "#ededed" }, |