Re: Wanted: Elegant way to manage this task
Re: Wanted: Elegant way to manage this task
- Subject: Re: Wanted: Elegant way to manage this task
- From: Graham Cox <email@hidden>
- Date: Wed, 10 Jun 2015 08:51:59 +1000
> On 9 Jun 2015, at 4:47 pm, Roland King <email@hidden> wrote:
>
>
> Without answering 98.7% of your question, or more. Are you wedded to NSData for this? I have a stream processor, it takes randomly chunked up data from a bluetooth dongle and .. processes it. I used dispatch_data_t for it. That was introduced back with GCD a few years ago. It’s proved very good for this kind of data manipulation. You can append them to each other, split them into pieces, iterate over them but under the hood all the while it keeps the original chunks of data and avoids a lot of copying around. Only if you at some point want N contiguous bytes out of the thing to process as a byte array will it do a copy if necessary into one single memory chunk, if the piece you want is already in one chunk, it just returns it to you. I’ve found it a good way to deal with buffers of bytes very efficiently and quite intuitively.
That sounds really great Roland!
I’m not wedded to NSData per se, it’s just that that’s how I get the data from a NSURLSession in the first place, so I was hoping to avoid too many copies. But if it makes the processing easier and the amount of copy space doesn’t become too large, it should be fine. Performance should not be a critical issue if the decoding is being done on a thread.
—Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden