Fastest way of writing NSData+extras to a file?
Fastest way of writing NSData+extras to a file?
- Subject: Fastest way of writing NSData+extras to a file?
- From: Jonathan del Strother <email@hidden>
- Date: Sun, 29 May 2005 18:00:00 +0100
I have some bitmap data in an NSData. There are also few associated
attributes such as image width, height & texture format.
I'd like to dump all of the above to a single file. Here's my
current approach (after initially trying to subclass NSData, failing,
and discovering all about Class Clusters):
@interface CompressedTextureFile : NSObject <NSCoding>
{
int width;
int height;
int format;
NSData* data;
}
So I then use archivers to encode these 4 attributes to disk & decode
them back again.
I don't care about the writing times, only the time to reconstruct
the objects from disk. Loading 100x132kb objects takes around 0.35
seconds.
Previously, I was ignoring the width, height & format, and just
writing the NSData to disk using writeToFile. Loading 100 NSData
objects using dataWithContentsOfFile took an average of 0.19 seconds
- nearly half the time of using the archiving technique!
I need this to be pretty fast. Is the composite object above the
best Cocoa-y way of dealing with this sort of data? Any suggestions
on other techniques I might try?
Thanks,
Jon
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden