Re: Referencing struct fields in C
Re: Referencing struct fields in C
- Subject: Re: Referencing struct fields in C
- From: Robert Martin <email@hidden>
- Date: Mon, 30 May 2011 14:04:22 -0400
What cured me of optimization-itis was this entry in ridiculousfish's ridiculously cool blog:
http://ridiculousfish.com/blog/archives/2010/07/23/will-it-optimize/#fish_made_a_mess
--Rob
>> One thing that bothers me though. How the compiler will understand
>> that the state is loop-invariant? Should I necessarily declare the
>> checked boolean state as a local stack variable (unlike to a class
>> member variable that may change as a side-effect, if foo() was a class
>> method)?
>
> No, just leave it. It can see that it's loop-invariant because it's passed in as a value to the function - within the function nothing ever changes its value. Copying it to another variable might do more harm than good (though I suspect the optimizer wouldn't be fazed by that).
>
> Another way to "optimise" in a simple manner is just to have two loops, one for true and one for false. Effectively that's how the optimizer rewrites your code anyway.
>
> --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