> On Nov 29, 2013, at 3:35 PM, Graham Cox <graham....@bigpond.com> wrote:
> > > On 29 Nov 2013, at 11:19 pm, Graham Cox <graham....@bigpond.com> wrote: > >>> You also have another, damn-quick "hash key" that takes zero disk access to >>> compute: -[NSData length]. >> >> Yep, that’s a great idea. > > > OK, I’ve implemented this much as your suggestion, and I’m also saving the > hash object along with the data so I can avoid recomputing it when the file > is imported. That’s not a good idea. If the file on disk changes out from under you, the cache no longer reflects the data. Reminiscent of the old adage: “There are only two hard problems in computer science: naming things, cache invalidation, and off-by-one errors.” If you really want to avoid computing hashes for all your embedded image data at load, you might consider deferring hash computation until absolutely necessary—that is, when inserting a file into a loaded document, only compute hashed for data objects which have the same length as the one you're in inserting. --Kyle Sluder _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com