Re: Recursive blocks
Re: Recursive blocks
- Subject: Re: Recursive blocks
- From: Chris Suter <email@hidden>
- Date: Fri, 28 Jan 2011 10:38:53 +1100
Hi Bill,
On Fri, Jan 28, 2011 at 4:51 AM, Bill Bumgarner <email@hidden> wrote:
> You have measured a situation where the pattern's marginal slowness actually
> matters?
No, of course not; I don't have a real world use case for it and, I
suspect, neither does anyone else.
> A Block_copy() is going to often be at least an order of magnitude (if not
> more) slower because it ends up causing a malloc(). Given that there will
> only be one allocation (or one assignment), it is likely that the overhead
> of either will be in the noise.
I was actually hinting at the slowness caused by using a block
variable. I forget exactly how many levels of indirection the block
variable incurs, three perhaps vs. a single call instruction, and
there's no way for the compiler to optimise it.
As you say, it's unlikely to make a difference but if you were to use
tail recursion and have a large number of iterations, then it might.
> I found the Blocks example to be more readable, but to each his own.
When I say readable, I also mean less prone to error. If you forget
the __block type qualifier, you don't get a compiler warning. Also if
you were stupid enough to reuse the block variable later that would
change the behaviour of the earlier block.
It also smells. Using a block variable to call yourself recursively is a hack.
Kind regards,
Chris
_______________________________________________
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