-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
compilerThe Swift compiler itselfThe Swift compiler itselfimprovementperformancetype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
Description
Previous ID | SR-1577 |
Radar | None |
Original Reporter | @josephlord |
Type | Improvement |
Additional Detail from JIRA
Votes | 2 |
Component/s | Compiler |
Labels | Improvement, Performance, TypeChecker |
Assignee | None |
Priority | Medium |
md5: ff256899ba0f3da0f98368b68df0de47
Issue Description:
A function with this line took about 4 seconds to compile in debug.
let sorted = picks.sort { $0.pick_line == $1.pick_line ? $0.position < $1.position : $0.pick_line < $1.pick_line }
This equivalent version took only 5.4ms:
let sorted = picks.sort {
if $0.pick_line == $1.pick_line {
return $0.position < $1.position
} else {
return $0.pick_line < $1.pick_line
}
}
picks
is an array of instances of an NSManagedObject subclass, position
and pick_line
are both optional Integer types. (I don't know if this is relevant).
Not sure if this should be labelled "Performance". Is that for issues in the compilation time or the performance of the compiled code.
Metadata
Metadata
Assignees
Labels
compilerThe Swift compiler itselfThe Swift compiler itselfimprovementperformancetype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis