decoration decoration
Stories

GROKLAW
When you want to know more...
decoration
For layout only
Home
Archives
Site Map
Search
About Groklaw
Awards
Legal Research
Timelines
ApplevSamsung
ApplevSamsung p.2
ArchiveExplorer
Autozone
Bilski
Cases
Cast: Lawyers
Comes v. MS
Contracts/Documents
Courts
DRM
Gordon v MS
GPL
Grokdoc
HTML How To
IPI v RH
IV v. Google
Legal Docs
Lodsys
MS Litigations
MSvB&N
News Picks
Novell v. MS
Novell-MS Deal
ODF/OOXML
OOXML Appeals
OraclevGoogle
Patents
ProjectMonterey
Psystar
Quote Database
Red Hat v SCO
Salus Book
SCEA v Hotz
SCO Appeals
SCO Bankruptcy
SCO Financials
SCO Overview
SCO v IBM
SCO v Novell
SCO:Soup2Nuts
SCOsource
Sean Daly
Software Patents
Switch to Linux
Transcripts
Unix Books

Gear

Groklaw Gear

Click here to send an email to the editor of this weblog.


You won't find me on Facebook


Donate

Donate Paypal


No Legal Advice

The information on Groklaw is not intended to constitute legal advice. While Mark is a lawyer and he has asked other lawyers and law students to contribute articles, all of these articles are offered to help educate, not to provide specific legal advice. They are not your lawyers.

Here's Groklaw's comments policy.


What's New

STORIES
No new stories

COMMENTS last 48 hrs
No new comments


Sponsors

Hosting:
hosted by ibiblio

On servers donated to ibiblio by AMD.

Webmaster
BUG!! | 151 comments | Create New Account
Comments belong to whoever posts them. Please notify us of inappropriate comments.
IF this is not de-minimis or merger
Authored by: Anonymous on Wednesday, May 16 2012 @ 12:27 PM EDT
...then what is?

[ Reply to This | Parent | # ]

9 lines of code = 3 statements + header
Authored by: Anonymous on Wednesday, May 16 2012 @ 01:05 PM EDT
They should have rewitten it:

void range_check(int array_len, int from_index, int to_index) {

if (array_len < to_index) throw out_of_bounds_error(to_index);

if (0 > from_index) throw out_of_bounds_error(from_index);

if (to_index < from_index) throw illegal_argument_error(description);

}

See how much more original that is? ;-)

[ Reply to This | Parent | # ]

9 lines of code = 3 statements + header
Authored by: Anonymous on Wednesday, May 16 2012 @ 01:37 PM EDT

There is a lot of research into how to count lines of code. Certainly one of the fastest, but least infomative, is to count the number of new line characters. In this case, the number of lines of code is 4. Let me reformat it a bit:

void range_check( int array_len, int from_index, int to_index )
{ if ( from_index > to_index ) throw illegal_argument_error( description );
if ( from_index if ( to_index > array_len ) throw out_of_bounds_error( to_index );
}

[ Reply to This | Parent | # ]

9 lines of code = 3 statements + header
Authored by: Chromatix on Wednesday, May 16 2012 @ 02:54 PM EDT

I'm not sure whether there s a strict requirement in the spec to throw an exception for these errors. If there isn't, then there's a completely different way to handle erroneous parameters, which is to adjust them or re-interpret them safely. To do this, we need to delete rangeCheck() entirely, and go to the single place in the TimSort code where it is called. By writing code inline, we get to adjust the variables rather than just being able to check them.

If we look there, we can see that rangeCheck() is simply called as a validation step, and there is a second validation step which recognises that a zero- element or one-element list is, by definition, already sorted. We can use that existing test to eliminate the need for one of the tests in rangeCheck - because if 'hi' is less than 'lo', the length will be negative and therefore is less than 2. (Note also that the same values have different names in this code.)

The remaining conditions can be satisfied by two simple statements, inserted instead of the call to rangeCheck():

if(hi > a.length) hi = a.length;
if(lo < 0) lo = 0;
This provides reasonable behaviour by causing TimSort to operate on the intersection of the full array and the specified range.

Of course, if the exception behaviour is specified, then there is little alternative to writing very similar code to what is in rangeCheck. However, it could still be made different by choosing different variable names, placing it inline to the sort() method instead of out-of-line, rewriting the exception message, or changing the order of the tests. Or, for that matter, adding a comment explaining why the exception behaviour is necessary.

It seems likely however that Bloch simply forgot that rangeCheck() was not an integral part of TimSort when he copied TimSort in. Probably he should have found an independent source for TimSort that was less likely to contain any Sun code.

[ Reply to This | Parent | # ]

BUG!!
Authored by: Anonymous on Wednesday, May 16 2012 @ 06:04 PM EDT

The valid indexes to an array of length are either 1..length or 0..length-1. C uses the latter. The example code allows both 0 and length, which is an error.

There is absolutely no way how three trivial comparisons should be copyrightable. Why? Because there are only 36 possible comparisons AT ALL you can do with three variables (from_index, to_index, length) and zero!

36 is the absolute maximum; it is calculated considering "smaller", "smaller or equal", "equal", "greater", and "greater or equal" as different comparisons. For integers, there really are only 25 unique comparisons between three variables and zero you can do. (For floating point values, there are more, because the rules say that a = a is not always true.)

It is literally like somebody just copyrighted three letters of the alphabet.

[ Reply to This | Parent | # ]

Groklaw © Copyright 2003-2013 Pamela Jones.
All trademarks and copyrights on this page are owned by their respective owners.
Comments are owned by the individual posters.

PJ's articles are licensed under a Creative Commons License. ( Details )