<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class="">On Apr 3, 2017, at 9:25 PM, Ben Rimmington via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><br class=""><blockquote type="cite" class="">On 3 Apr 2017, at 17:55, Tony Allevato wrote:<br class=""><br class="">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)?<br class=""></blockquote><br class="">Is this a regression since Swift 2.0 added the optimization?<br class=""></div></div></blockquote><div><br class=""></div><div>I'd say it's a regression since 3.0 since I remember testing the optimizer even being able to put together this during compile time:</div><div><br class=""></div><div>struct URLString {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>let urlString: String</div><div><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>init(host: String, path: String, query: String) {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>self.urlString = "http://" + host + path + "?" + query</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div>}</div><div><br class=""></div><div>URLString(host: "<a href="http://apple.com" class="">apple.com</a>", path: "/mac", query: "target=imac")</div><div><br class=""></div><div>This produced a single string literal - I confirmed this using MachOView on the final binary...</div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>* Concatenation of Swift string literals, including across multiple lines, is<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp;now a guaranteed compile-time optimization, even at `-Onone`. **(19125926)**<br class=""><br class="">&lt;<a href="https://github.com/apple/swift/blame/97db3931f2c5a21ea87ad6e71cdecbec325bff91/CHANGELOG.md#L1329-L1330" class="">https://github.com/apple/swift/blame/97db3931f2c5a21ea87ad6e71cdecbec325bff91/CHANGELOG.md#L1329-L1330</a>&gt;<br class=""><br class="">-- Ben<br class=""><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></div></blockquote></div><br class=""></body></html>