<div dir="ltr">Interesting, thanks!<div>I tried using this extension</div><div><div>extension String {</div><div> func componentsSeparatedByNewLineCharacter() -> [String] {</div><div> var lines = [String]()</div><div> var currStr = String.UnicodeScalarView()</div><div> let newLineUCS = UnicodeScalar("\n")</div><div> for ucs in self.unicodeScalars {</div><div> switch ucs {</div><div> case newLineUCS: lines.append(String(currStr)); currStr.removeAll()</div><div> default: currStr.append(ucs)</div><div> }</div><div> }</div><div> return lines</div><div> }</div><div>}</div></div><div>instead of componentsSeparatedByString("\n")</div><div><br></div><div>This made the slow non-caseSwapped test(strings) run in 2.3 seconds instead of the previous 9.5 seconds, but that is still relatively slow compared to the 0.066 seconds of the test(caseSwappedStrings).</div><div><br></div><div>Is there a way to make sure a String in Swift has the isASCII bit set (provided the original string contains only ASCII of course)?</div><div><div><br></div><div>/Jens</div></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 2, 2016 at 7:24 PM, Daniel Duan via swift-dev <span dir="ltr"><<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Arnold Schwaighofer via swift-dev <swift-dev <at> <a href="http://swift.org" rel="noreferrer" target="_blank">swift.org</a>> writes:<br>
<br>
><br>
> That is the difference between a “String” type instance that can use the<br>
> ascii fast path and NSString backed “String” type instances.<br>
><br>
<br>
</span>This makes total sense now :) I was very mystified by this issue and thought<br>
it's a weird bias in the hashing function at some point.<br>
<br>
Thanks for the insight Arnold.<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
swift-dev mailing list<br>
<a href="mailto:swift-dev@swift.org">swift-dev@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-dev" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">bitCycle AB | Smedjegatan 12 | 742 32 Östhammar | Sweden<br><a href="http://www.bitcycle.com/" target="_blank">http://www.bitcycle.com/</a><br>Phone: +46-73-753 24 62<br>E-mail: <a href="mailto:jens@bitcycle.com" target="_blank">jens@bitcycle.com</a><br><br></div>
</div>