[SR-12125] String(decoding:from:)
doesn't try withContiguousStorageIfAvailable
#54560
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
performance
standard library
Area: Standard library umbrella
Attachment: Download
Environment
swift 5.1 and 5.2 branch
Additional Detail from JIRA
md5: 4785e0cdc39c1c82c168b48e24fef33d
Issue Description:
String(decoding:from🙂
does sometimes make intermediate Array copies of the Collection that it receives. That makes sense because the collection might not be contiguous. If however the collection implementswithContiguousStorageIfAvailable
, thenString(decoding:from🙂
should use this.The attached program shows this (parts reproduced here):
If we look at all allocations that happen more than once we see only
so
doMyCollection
allocates 10,000 times butdoMyCollectionUnsafe
does not.repro
The text was updated successfully, but these errors were encountered: