[swift-evolution] Faster/lower-level external String initialization
Jacob Bandes-Storch
jtbandes at gmail.com
Sat Jan 9 00:02:14 CST 2016
I think it would be more appropriate to use `init(utf8:
UnsafeBufferPointer<UInt8>)`, which comprises both a base pointer and a
length.
Jacob Bandes-Storch
On Fri, Jan 8, 2016 at 9:58 PM, Charles Kissinger via swift-evolution <
swift-evolution at swift.org> wrote:
> The String initializer that would actually be of most value to me would be:
>
> String.init(utf8: UnsafePointer<UInt8>, length: Int)
>
> as long as it is as fast (preferably faster) than String.fromCString() and
> doesn’t require bridging to NSString. A similar initializer is available
> for NSString, but as Zach indicated in his link, using it is slow.
>
> Several other initializers, including the one you showed, would be useful,
> as long as they are performant.
>
> —CK
>
> On Jan 8, 2016, at 9:04 PM, 品雪 via swift-evolution <
> swift-evolution at swift.org> wrote:
>
> Sorry, I didn't get it, are you talking about:
>
> var bytes : [UInt8] = [65, 66, 67, 68, 69, 70];
> var s = String.init(bytes: bytes, encoding: NSUTF8StringEncoding)
>
> ?
>
> On Sat, Jan 9, 2016 at 8:22 AM, T.J. Usiyan via swift-evolution <
> swift-evolution at swift.org> wrote:
>
>> I support this change as well.
>>
>> TJ
>>
>> On Fri, Jan 8, 2016 at 6:06 PM, Guillaume Lessard via swift-evolution <
>> swift-evolution at swift.org> wrote:
>>
>>> Complete agreement from me. I would like to see a String constructor
>>> from a Sequence of code units.
>>> Also, why is String.fromCString() a factory function rather than a
>>> fallible constructor?
>>>
>>> Guillaume Lessard
>>>
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution at swift.org
>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>>
>>
>>
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>
>>
>
>
> --
> Best Regards!
>
> Yang Wu
> --------------------------------------------------------
> Location: Pudong, Shanghai, China.
> EMail : pinxue at gmail.com
> Website: http://www.time2change.mobi http://rockplayer.com
> Twitter/Weibo : @pinxue
> <http://www.pinxue.net/>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160108/73d5df61/attachment.html>
More information about the swift-evolution
mailing list