• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Fast hash of NSData?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fast hash of NSData?


  • Subject: Re: Fast hash of NSData?
  • From: Kyle Sluder <email@hidden>
  • Date: Fri, 29 Nov 2013 15:41:36 -0800

> On Nov 29, 2013, at 3:35 PM, Graham Cox <email@hidden> wrote:

>
>
> On 29 Nov 2013, at 11:19 pm, Graham Cox <email@hidden> 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 (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


  • Follow-Ups:
    • Re: Fast hash of NSData?
      • From: Graham Cox <email@hidden>
References: 
 >Fast hash of NSData? (From: Graham Cox <email@hidden>)
 >Re: Fast hash of NSData? (From: Kyle Sluder <email@hidden>)
 >Re: Fast hash of NSData? (From: Graham Cox <email@hidden>)
 >Re: Fast hash of NSData? (From: Kyle Sluder <email@hidden>)
 >Re: Fast hash of NSData? (From: Graham Cox <email@hidden>)
 >Re: Fast hash of NSData? (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Fast hash of NSData?
  • Next by Date: Re: Fast hash of NSData?
  • Previous by thread: Re: Fast hash of NSData?
  • Next by thread: Re: Fast hash of NSData?
  • Index(es):
    • Date
    • Thread