[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] RE: [Xen-devel] [PATCH] cpufreq.c: shut up compiler about cpufreq_dom
Liu, Jinsong writes ("RE: [Xen-devel] [PATCH] cpufreq.c: shut up > What's the advantage of the above coding style? seems it saved a > flag but add 1 more jump. It's clearer, and the compiler can see what's going on. There isn't another jump `as written', since `break' is a jump too. Whether there is another jump after the compiler is done with it depends on a lot of factors, but generally I would expect the compiler to do a better job when information about the program's possible behaviours is represented directly in the control flow than when it is stored in a flag variable. For example, often the allocation of a new structure can be done directly at the point where we fall out of the loop, eg: > > for (...) { cpufreq_dom = dom; if (...) goto cpufreq_dom_found; } cpufreq_dom = xmalloc(...); cpufreq_dom->contents = value; ... > > cpufreq_dom_found: Ian. _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |