<html><body><div id="edo-message"><div>I didn't know that normally-copying initialiser was non-copying for ContiguousArray. That's the kind of thing we should really document somewhere (or it should be it's own function because it guarantees non-copying behaviour).</div><div><br></div><div>If you're using CA explicitly, it's because you want those subtle performance guarantees.</div><div><br></div><div>Karl<br><br><div style="font-family: 'Helvetica Neue','Helvetica',Helvetica,Arial,sans-serif;font:'-apple-system-body';">Sent from my new <a href="https://itunes.apple.com/app/apple-store/id922793622?pt=814382&mt=8&ct=my_new_email">Email</a></div></div></div><div id="edo-original"><div><br><br><blockquote type="cite" style="margin:1ex 0 0 0;border-left:1px #ccc solid;padding-left:0.5ex;"><div>On Jul 28, 2016 at 10:32 AM, <<a href="mailto:gribozavr@gmail.com">Dmitri Gribenko</a>> wrote:<br><br></div><div><pre>On Wed, Jul 27, 2016 at 11:08 PM, Karl via swift-evolution
<br><<a dir="ltr" href="mailto:swift-evolution@swift.org" x-apple-data-detectors="true" x-apple-data-detectors-type="link" x-apple-data-detectors-result="2">swift-evolution@swift.org</a>> wrote:
<br>> It seems like a reasonably large hole with a simple fix. Going from
<br>> ContiguousArray to Array is a kind-of upcasting conversion and should be
<br>> allowed -- it seems like that's almost the whole point of the type.
<br>
<br>Hi Karl,
<br>
<br>Converting a ContiguousArray to Array using Array's initializer is
<br>O(1). Are you seeing something different?
<br>
<br>Array.init:
<br>
<br><a dir="ltr" href="https://github.com/apple/swift/blob/f8f6d61d195185f54aeba425dd0db8be4c5d163f/stdlib/public/core/Arrays.swift.gyb#L1037" x-apple-data-detectors="true" x-apple-data-detectors-type="link" x-apple-data-detectors-result="4">https://github.com/apple/swift/blob/f8f6d61d195185f54aeba425dd0db8be4c5d163f/stdlib/public/core/Arrays.swift.gyb#L1037</a>
<br>
<br>ContiguousArray._copyToContiguousArray():
<br>
<br><a dir="ltr" href="https://github.com/apple/swift/blob/f8f6d61d195185f54aeba425dd0db8be4c5d163f/stdlib/public/core/Arrays.swift.gyb#L1430" x-apple-data-detectors="true" x-apple-data-detectors-type="link" x-apple-data-detectors-result="5">https://github.com/apple/swift/blob/f8f6d61d195185f54aeba425dd0db8be4c5d163f/stdlib/public/core/Arrays.swift.gyb#L1430</a>
<br>
<br>Dmitri
<br>
<br>--
<br>main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
<br>(j){printf("%d\n",i);}}} /*Dmitri Gribenko <<a dir="ltr" href="mailto:gribozavr@gmail.com" x-apple-data-detectors="true" x-apple-data-detectors-type="link" x-apple-data-detectors-result="6">gribozavr@gmail.com</a>>*/
<br></pre></div></blockquote></div></div></body></html>