Re: Efficiency of loading Localizable.strings and NSUserDefaults
Re: Efficiency of loading Localizable.strings and NSUserDefaults
- Subject: Re: Efficiency of loading Localizable.strings and NSUserDefaults
- From: Jean-Daniel Dupas <email@hidden>
- Date: Thu, 16 Jul 2009 09:39:25 +0200
Le 16 juil. 09 à 04:55, Graham Cox a écrit :
On 16/07/2009, at 6:45 AM, Development wrote:
Anyone has some comments or ideas about this? Possibly someone
with some inner understanding of how localized strings are read?
Optimise later. You are fretting about the speed of loading strings
to the point where you are considering your own look-up scheme - a
problem that Cocoa has already solved for you. And all without doing
any measurement (presumably - you don't mention any profiling
figures).
Here's a fact - *drawing* a string takes aeons compared to the time
needed to get that string in place ready to be drawn. So no matter
how fast you load the strings, your performance will be graphics/
drawing time bound.
You mention these being error strings - I find it hard to imagine
why performance here matters. Are you wishing to display errors at
hundreds of frames per second? How is the user expected to read them?
Keep your code simple - use the NSLocalizedString macro or one of
the localised string loading methods and worry about performance
later if it proves (by actual measurement) necessary.
Again, anyone has thoughts or comments about the inner working of
NSUserDefaults?
Same thing. Read from the defaults as needed. As far as I can tell,
NSUserDefaults is basically a disk-backed dictionary, and is kept in
memory. Access can be assumed to be fast, or at least fast enough,
unless actual measurement shows otherwise. As for flushing to disk
every time in case of a crash, I'd say don't even if that is Apple's
apparent advice [citation needed].
I don't think you will find this citation in the NSUserDefaults doc.
From the -synchronize method:
Discussion
Because this method is automatically invoked at periodic intervals,
use this method only if you cannot wait for the automatic
synchronization (for example, if your application is about to exit) or
if you want to update the user defaults to what is on disk even though
you have not made any changes.
And from the CFPreferences User Guide:
The Rule of Thumb on CFPreferences synchronization:
Only synchronize when absolutely necessary_______________________________________________
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