[swift-users] Why does String.CharacterView have reserveCapacity(:)?

Kelvin Ma kelvin13ma at gmail.com
Tue May 2 14:35:47 CDT 2017


I’m wondering why the String.CharacterView structure has a
reserveCapacity(:) member? And even more strangely, why String itself has
the same method?

It’s even weirder that String.UnicodeScalarView has this method, but it
reserves `n` `UInt8`s of storage, instead of `n` `UInt32`s of storage. Also
why String.UTF8View and String.UTF16View do not have this method, when it
would make more sense for them to have it than for String itself and
String.CharacterView to have it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170502/f7de0d90/attachment.html>


More information about the swift-users mailing list