Skip to content

Instantly share code, notes, and snippets.

@acrookston acrookston/fast_code.swift
Last active Feb 19, 2018

Embed
What would you like to do?
This code takes several minutes (3min on MacBook Pro i5 2.4Ghz) to compile
struct Test {
let computed: Int
init(a: Int, b: Int, c: Int, d: Int, e: Int = 0, f: Int = 0, g: Int = 0, h: Int = 0) {
var value: Int = (a << 56)
value |= (b << 48)
value |= (c << 40)
value |= (d << 32)
value |= (e << 24)
value |= (f << 16)
value |= (g << 8)
value |= h
computed = value
}
}
time /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file compiler_test.swift -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -I ~/Library/Developer/Xcode/DerivedData/compiler-evaxhfqitakxmeawlpgvnjggyejp/Build/Products/Debug -F ~/Library/Developer/Xcode/DerivedData/compiler-evaxhfqitakxmeawlpgvnjggyejp/Build/Products/Debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -enable-testing -g -module-cache-path ~/Library/Developer/Xcode/DerivedData/ModuleCache -swift-version 4 -enforce-exclusivity=checked -D SWIFT_PACKAGE -D Xcode -serialize-debugging-options -report-errors-to-debugger -Xcc -I~/Library/Developer/Xcode/DerivedData/compiler-evaxhfqitakxmeawlpgvnjggyejp/Build/Intermediates.noindex/compiler.Store -index-system-modules
struct Test {
let computed: Int
init(a: Int, b: Int, c: Int, d: Int, e: Int = 0, f: Int = 0, g: Int = 0, h: Int = 0) {
computed = (a << 56) | (b << 48) | (c << 40) | (d << 32) | (e << 24) | (f << 16) | (g << 8) | h
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.