[stdlib] add two-operand version of max and use max2 in stdlib when appropriate.

This helps array append's performance by ~ 2x. The generic max with a variadic
argument creates a temporary array then iterates over the array.

rdar://17140639 rdar://17073827


Swift SVN r18764
This commit is contained in:
Manman Ren
2014-06-09 23:56:40 +00:00
parent c8ac91e4c7
commit cc90c81239
6 changed files with 16 additions and 8 deletions

View File

@@ -312,6 +312,14 @@ func min<T : Comparable>(x: T, y: T, rest: T...) -> T {
return r
}
func max2<T : Comparable>(x: T, y: T) -> T {
var r = y
if y < x {
r = x
}
return r
}
func max<T : Comparable>(x: T, y: T, rest: T...) -> T {
var r = y
if y < x {