Re: [PATCH 8/8] diff: improve positioning of add/delete blocks in diffs
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 4, 2016, 19:47 UTC
- Message-ID
- <xmqq8twc2u5v.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <CAGZ79kYCwoo6sYefu++KyCdgHfKvRsUp98ZAur+E7E4o_FLtEw@mail.gmail.com>
Stefan Beller <sbeller@google.com> writes:
Show 9 quoted lines
> I have just reread the scoring function and I think you could pull out the > `score=indent` assignment (it is always assigned except for indent <0) > > if (indent == -1) > score = 0; > else > score = indent; > ... lots of bonus computation below, which in its current implementation > have lots of "score = indent;" lines as well.
Yup. If each part in this if/else if/... cascade independently sets complete information (i.e. both "bonus" and "score") necessary for the final result, then I do not mind the same "score = indent" in many of them (these case happen to get the same score), but that is not what we have in this code (i.e. "bonus" has a shared component that is not affected by thie if/else if/ cascade), so setting score to indent upfront and reset it to 0 only on a blank line would make sense.