lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fix uninitialized variables when Source_file::get_counts returns ear


From: Dan Eble
Subject: Re: Fix uninitialized variables when Source_file::get_counts returns early due to !contains (pos_str0) (issue 4940047)
Date: Wed, 24 Aug 2011 09:01:55 -0400

On 2011-08-24, at 05:10 , Reinhold Kainhofer wrote:

> Am Wednesday, 24. August 2011, 10:49:30 schrieben Sie:
>> Hi  Graham, Carl,
>> 
>> On Tue 23 Aug 2011 19:34:37 BST, Carl Sorensen wrote:
>>> On 8/23/11 12:21 PM, "address@hidden" <address@hidden> wrote:
>>>> Maybe we should have some GOP rules for C++ about this?
>>>> "Only have multiple exit points from routines if you absolutely have to.
> 
> There is really not much difference in
> 
> if (some_condition)
>  return;
> 
> and
> 
> if (!some_condition)
>  {
>    ....
>  }
> 
> Except that if you have many conditions the indentation in the second example 
> will be terrible and make the whole thing hard to read.


There can be a run-time performance difference between branching or not 
branching.  For the times you actually care, if you're not going to use 
compiler-specific features to mark conditions as likely or unlikely, you should 
test the likely case first so that there is no branching most of the time.

> You can mess up equally with both.

Some of us have. :-)

You can also write functions that are equally difficult to read with both.  The 
readability depends more on what is inside your ellipsis above than whether the 
unexpected condition is handled before or after it.
-- 
Dan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]