[swift-evolution] [Draft proposal] Faster/lower-level external String initialization

Guillaume Lessard glessard at tffenterprises.com
Fri Jan 15 17:26:59 CST 2016


> On 15 janv. 2016, at 16:15, Max Moiseev <moiseev at apple.com> wrote:
> 
>> On Jan 15, 2016, at 3:06 PM, Guillaume Lessard <glessard at tffenterprises.com> wrote:
>> 
>> With pointers, there some kind of nullness check either way; I would personally prefer to do it on an optional String than a probable Pointer. I guess it’s just a matter of picking a poison.
> Another point is, you will have 2 checks then: one inside the function and one outside of it. Versus a single check upfront.

The precondition involves a check, so there’s 2 checks either way. Either a) you check for a null pointer before, then the function does it again before deciding whether to crash, or b) the function checks it before deciding whether to return Optional.None, and then you have to unwrap the optional...

Cheers,
Guillaume Lessard



More information about the swift-evolution mailing list