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
Compiled with: | |
~/bin/clang/bin/clang -O3 -Rpass=loop-vectorize -Rpass-missed=loop-vectorize -Rpass-analysis=loop-vectorize -isysroot /Volumes/Data/Users/ken/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -framework Foundation /tmp/testcomp/testcomp/main.m | |
Interesting part of diagnostic output: | |
/tmp/testcomp/testcomp/main.m:57:13: remark: vectorized loop (vectorization factor: 16, unrolling interleave factor: 1) [-Rpass=loop-vectorize] | |
testBuffer[i] = (bytes[i] >= 128); | |
^ | |
output: | |
2014-12-03 11:33:33.070 a.out[48363:2396624] shortLen: 6 longLen:2493109 |
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
% swiftc -Xllvm -help-hidden /tmp/foo.swift | |
USAGE: swift (LLVM option parsing) [options] | |
OPTIONS: | |
-a9-754319-workaround - Enable workarounds for A9 HW bugs #754319 | |
-a9-754320-workaround - Enable workarounds for A9 HW bugs #754320 | |
-aarch64-use-tbi - Assume that top byte of an address is ignored | |
-agg-antidep-debugdiv=<int> - Debug control for aggressive anti-dep breaker | |
-agg-antidep-debugmod=<int> - Debug control for aggressive anti-dep breaker | |
-aggressive-ext-opt - Aggressive extension optimization |
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 é = "precomposed character!" | |
let é = "decomposed characters!" | |
println(é) // prints "precomposed character!" | |
println(é) // prints "decomposed 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
func logWrap<Domain,Range>(f : Domain->Range) -> Domain->Range { | |
return { (args:Domain) -> Range in | |
println("called me!") | |
return f(args) | |
} | |
} | |
func foo(a:Int, b:Int)->Int { | |
return a + b | |
} |
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
@interface UIView (LayoutConvenience) | |
- (NSLayoutConstraint *)constraintAligningAttribute:(NSLayoutAttribute)attr withView:(UIView *)otherView; | |
@end | |
@implementation UIView (LayoutConvenience) | |
- (NSLayoutConstraint *)constraintAligningAttribute:(NSLayoutAttribute)attr withView:(UIView *)otherView { | |
return [NSLayoutConstraint constraintWithItem:self attribute:attr relatedBy:NSLayoutRelationEqual toItem:otherView attribute:attr multiplier:1.0 constant:0.0]; | |
} | |
@end |
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
2014-09-21 11:21:04.807 ALtest[42953:7217373] Unable to simultaneously satisfy constraints. | |
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) | |
/// As it says, we need to read the constraints one by one and see if there's one that says something we don't want. | |
( | |
"<NSLayoutConstraint:0x7f9e39f344f0 H:[UIButton:0x7f9e39f339d0'1'(20)]>", | |
/// first button is width 20 – ***I bet you didn't want this and it needs to be deleted*** | |
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
func foo() { | |
func bar(x:Int)->String { | |
return "hello" | |
} | |
[1,2,3].map({bar($0)}) // "Cannot reference a local function from another local function" | |
} |
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
func benchmark<T>(label:String, body:()->T) { | |
var info = mach_timebase_info_data_t(numer: 0, denom: 0) | |
mach_timebase_info(&info) | |
let tick = mach_absolute_time() | |
let res = body() | |
let tock = mach_absolute_time() | |
let delta = tock - tick | |
let nanos = delta * UInt64(info.numer) / UInt64(info.denom) |
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
func foo(f:()->(Int?)) { | |
println(f()) | |
} | |
let bar : ()->Int = { 3 } | |
// foo shouldn't be able to take bar, should it? | |
foo(bar) // prints Optional(3) | |
// you're freaking me out, Swift. Did it allocate a wrapping closure? |
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
operator infix !|| { associativity right precedence 100 } // associativity/precedence copied from ternary ? : | |
@infix func !||<T>(lhs:T?, rhs:@auto_closure ()->T) -> T { | |
switch lhs { | |
case nil: return rhs() | |
case _: return lhs! | |
} | |
} |