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: Graham Cox <email@hidden>
- Date: Thu, 16 Jul 2009 12:55:07 +1000
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]. Your app should not crash -
concentrate on fixing it if it has a tendency to, rather than
introduce performance bottlenecks that could affect your whole app all
the time, "just in case". Two wrongs don't make a right.
Don't sweat the details - code simply. Measure. Optimise *if
necessary*. I bet you'll find it won't be, and you've saved yourself a
ton of work (and sweat).
--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