[swift-server-dev] Byte Bucket Protocol

steve algernon salgernon at apple.com
Thu Nov 3 17:40:41 CDT 2016


> On Nov 3, 2016, at 1:46 PM, Chris Bailey via swift-server-dev <swift-server-dev at swift.org> wrote:
> 
> > Well, GCD is already an example which does not use NSData but DispatchData. So if everything else is based on NSData, a GCD client would need to map/copy the DispatchData into an NSData. 
> 
> Which is something that Foundation itself has to do for URLSession - I think its a pretty direct mapping, but there would be wider benefits of solving that issue.

In ObjC dispatch_data_t is effectively toll-free-bridged with NSData, but when people want a flattened representation and they invoke -bytes, a new mapping has to be created into which the contiguous bytes are copied.

For this reason, we recommend using -[NSData enumerateByteRangesUsingBlock:] from now on.  Obviously sometimes you need a contiguous buffer, but at least we can defer the copying as much as possible if concatenating dispatch_data objects.

--sma

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-server-dev/attachments/20161103/dd217d11/attachment.html>


More information about the swift-server-dev mailing list