Re: Mutable arrays
Re: Mutable arrays
- Subject: Re: Mutable arrays
- From: "Michael Ash" <email@hidden>
- Date: Mon, 20 Oct 2008 18:02:43 -0400
On Mon, Oct 20, 2008 at 11:45 AM, I. Savant <email@hidden> wrote:
> On Mon, Oct 20, 2008 at 11:37 AM, Roland King <email@hidden> wrote:
>
>> I'm not sure I totally agree with step 0. I think there is value in
>> understanding how your code is going to run, or is going to run most times,
>> and picking constructs which are clearly efficient if it's really not more
>> work to do so and it represents the data you're working with.
>
> Agreed. "The laptops! Won't somebody PLEASE think of the LAPTOPS!"
>
> Sure, our desktops are fast and the difference in 'extra work saved'
> is usually imperceptible, but my laptop thanks you for your judicious
> use of reasonably-optimized code. Mobile users need you to not waste
> their battery power on pointless code execution.
Doesn't matter what you're running, because I don't advocate ignoring
speed. Rather, I advocate a plan of action which produces the fastest
code in the end. The simple fact is that most code is already fast
enough, and should not be optimized. The effort that would go into
optimizing it should instead be directed to the code where it can
actually make a difference. The end result is an app that's faster
than if you optimized everything.
In the case of -initWithCapacity:, it's a very little effort being
expended. But it's also a very little gain being realized. So it's
better to leave off that little bit of mental effort altogether so
that it might later be used in a place where it can do some more good.
(And lastly, even "obvious" optimizations like preallocating memory
can backfire. And you'll never know if it backfired unless you have
both before and after measurements. So putting in the time to optimize
code up front can give you a worse overall result even for that
particular piece of code, let alone the entire app.)
Mike
_______________________________________________
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