Mark the concatination of two strings as @readonly.

Swift SVN r21061
This commit is contained in:
Nadav Rotem
2014-08-06 05:19:51 +00:00
parent 2217b29956
commit d96e940c36
2 changed files with 10 additions and 0 deletions

View File

@@ -265,6 +265,7 @@ extension String : StringInterpolationConvertible {
public static func convertFromStringInterpolationSegment<T>(expr: T) -> String { return toString(expr) } public static func convertFromStringInterpolationSegment<T>(expr: T) -> String { return toString(expr) }
} }
@semantics("readonly")
public func +(var lhs: String, rhs: String) -> String { public func +(var lhs: String, rhs: String) -> String {
if (lhs.isEmpty) { if (lhs.isEmpty) {
return rhs return rhs
@@ -273,6 +274,7 @@ public func +(var lhs: String, rhs: String) -> String {
return lhs return lhs
} }
@semantics("readonly")
public func +(lhs: Character, rhs: Character) -> String { public func +(lhs: Character, rhs: Character) -> String {
var result = String(lhs) var result = String(lhs)
result += String(rhs) result += String(rhs)

View File

@@ -66,3 +66,11 @@ func string_interpolation() {
func string_interpolation2() { func string_interpolation2() {
"\(false) \(true)" "\(false) \(true)"
} }
//CHECK-LABEL: string_plus
//CHECK: bb0:
//CHECK-NEXT: tuple
//CHECK-NEXT: return
func string_plus() {
"a" + "b"
}