On Tue, Dec 9, 2008 at 6:31 PM, I. Savant <[EMAIL PROTECTED]> wrote: > >> Even if it were slower, contorting the code like this without >> having profiled the code and demonstrated that this is in fact a >> significant slowdown is bad practice. > > I disagree. Certainly it's "profile first", but to have a view that reads a > simple property from user defaults every time it draws requires more > overhead than using an instance variable. Especially when you're using an > NSColor object which must be properly archived and unarchived.
Of course it uses more overhead. But the point is that in the big picture, the increased vs decreased overhead is unimportant. It doesn't matter whether you spend 1ns fetching a color from an ivar vs 1us fetching a color from user defaults when you're going to subsequently spend 1ms drawing with that color. > Imagine adding complexity to this view and using multiple values like this > per draw cycle, and having to draw a whole bunch of stuff. Directly reading > colors from user defaults is suddenly a whole lot more expensive. > > It doesn't matter much for the simple case the OP presented, but it > certainly does for a custom view that does heavy drawing, especially if it's > involved in an animation. Doing something repeatedly doesn't suddenly catapult marginal overhead into being important. If it takes a fraction of a percent in the simple case it'll take a fraction of a percent in the high-demand animated case too. Mike _______________________________________________ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]