Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4110)

Issue 22750045: optimal-page-breaking.cc protect unsigned subtraction; issue 1553

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 5 months ago by Keith
Modified:
10 years, 5 months ago
Reviewers:
janek, dak, lemzwerg
CC:
lilypond-devel_gnu.org
Visibility:
Public.

Description

description

Patch Set 1 #

Total comments: 1

Patch Set 2 : explicit saturating subtraction #

Total comments: 1

Patch Set 3 : peephole optimization #

Unified diffs Side-by-side diffs Delta from patch set Stats (+3 lines, -1 line) Patch
M lily/optimal-page-breaking.cc View 1 2 1 chunk +3 lines, -1 line 0 comments Download

Messages

Total messages: 6
lemzwerg
LGTM.
10 years, 5 months ago (2013-11-14 05:50:07 UTC) #1
janek
LGTM. I think that this would warrant a comment (it's quite surprising that min_sys_count could ...
10 years, 5 months ago (2013-11-17 14:31:28 UTC) #2
dak
https://codereview.appspot.com/22750045/diff/1/lily/optimal-page-breaking.cc File lily/optimal-page-breaking.cc (right): https://codereview.appspot.com/22750045/diff/1/lily/optimal-page-breaking.cc#newcode120 lily/optimal-page-breaking.cc:120: for (vsize sys_count = ideal_sys_count + 1; --sys_count >= ...
10 years, 5 months ago (2013-11-20 08:53:24 UTC) #3
dak
https://codereview.appspot.com/22750045/diff/20001/lily/optimal-page-breaking.cc File lily/optimal-page-breaking.cc (right): https://codereview.appspot.com/22750045/diff/20001/lily/optimal-page-breaking.cc#newcode78 lily/optimal-page-breaking.cc:78: if (min_sys_count > ideal_sys_count) // subtraction wrapped around How ...
10 years, 5 months ago (2013-11-21 09:34:46 UTC) #4
Keith
On Thu, 21 Nov 2013 01:34:46 -0800, <dak@gnu.org> wrote: > How about > if (min_sys_count ...
10 years, 5 months ago (2013-11-22 04:29:01 UTC) #5
dak
10 years, 5 months ago (2013-11-22 06:08:03 UTC) #6
"Keith OHara" <k-ohara5a5a@oco.net> writes:

> On Thu, 21 Nov 2013 01:34:46 -0800, <dak@gnu.org> wrote:
>
>> How about
>> if (min_sys_count > ideal_sys_count // subtraction wrapped around
>>     || min_sys_count <= 0)
>>    min_sys_count = 1;
>>
>> Saves you the min thing.
>
> That is compact, but I want to keep the min thing separate for code
> history.  The two fixups of min_sys_count came from different people
> at different times.

So what?

> This code is not run often enough that I worry about an extra test and
branch.

I worry about robustness and readability.  This checks min_syscount to
be in range and corrects it if is out of range.  The current proposal
takes two different operations, bounces it back and forth, and needs a
min operation with casts.

-- 
David Kastrup
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b