[swift-evolution] multi-line string literals.

Ben Rimmington me at benrimmington.com
Mon Apr 3 14:25:59 CDT 2017


> On 3 Apr 2017, at 17:55, Tony Allevato wrote:
> 
> I just checked with -O and without and was surprised to find that `let x = "abc" + "def" + "ghi"` wasn't collapsed into a single string literal "abcdefghi" in the generated assembly code. Maybe it's more difficult than it is in some other languages because of operator overloads and different kinds of text literals (strings, extended grapheme clusters, Unicode scalars)?

Is this a regression since Swift 2.0 added the optimization?

	* Concatenation of Swift string literals, including across multiple lines, is
	  now a guaranteed compile-time optimization, even at `-Onone`. **(19125926)**

<https://github.com/apple/swift/blame/97db3931f2c5a21ea87ad6e71cdecbec325bff91/CHANGELOG.md#L1329-L1330>

-- Ben



More information about the swift-evolution mailing list