mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Mark the concatination of two strings as @readonly.
Swift SVN r21061
This commit is contained in:
@@ -265,6 +265,7 @@ extension String : StringInterpolationConvertible {
|
||||
public static func convertFromStringInterpolationSegment<T>(expr: T) -> String { return toString(expr) }
|
||||
}
|
||||
|
||||
@semantics("readonly")
|
||||
public func +(var lhs: String, rhs: String) -> String {
|
||||
if (lhs.isEmpty) {
|
||||
return rhs
|
||||
@@ -273,6 +274,7 @@ public func +(var lhs: String, rhs: String) -> String {
|
||||
return lhs
|
||||
}
|
||||
|
||||
@semantics("readonly")
|
||||
public func +(lhs: Character, rhs: Character) -> String {
|
||||
var result = String(lhs)
|
||||
result += String(rhs)
|
||||
|
||||
@@ -66,3 +66,11 @@ func string_interpolation() {
|
||||
func string_interpolation2() {
|
||||
"\(false) \(true)"
|
||||
}
|
||||
|
||||
//CHECK-LABEL: string_plus
|
||||
//CHECK: bb0:
|
||||
//CHECK-NEXT: tuple
|
||||
//CHECK-NEXT: return
|
||||
func string_plus() {
|
||||
"a" + "b"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user