Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(826)

Issue 11144016: Make argument of List.sort optional with default Comparable.compare. (Closed)

Created:
8 years, 2 months ago by Lasse Reichstein Nielsen
Modified:
8 years, 2 months ago
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Make argument of List.sort optional with default Comparable.compare. BUG=1235 Committed: https://code.google.com/p/dart/source/detail?r=13718

Patch Set 1 #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+14 lines, -7 lines) Patch
M lib/compiler/implementation/lib/interceptors.dart View 1 chunk +7 lines, -2 lines 2 comments Download
M lib/core/list.dart View 1 chunk +1 line, -1 line 0 comments Download
M runtime/lib/array.dart View 2 chunks +2 lines, -2 lines 0 comments Download
M runtime/lib/growable_array.dart View 1 chunk +1 line, -1 line 0 comments Download
M tests/corelib/list_sort_test.dart View 1 chunk +3 lines, -1 line 2 comments Download

Messages

Total messages: 5 (0 generated)
Lasse Reichstein Nielsen
8 years, 2 months ago (2012-10-15 08:59:57 UTC) #1
Johnni Winther
lgtm
8 years, 2 months ago (2012-10-15 10:46:43 UTC) #2
ngeoffray
https://codereview.chromium.org/11144016/diff/1/lib/compiler/implementation/lib/interceptors.dart File lib/compiler/implementation/lib/interceptors.dart (right): https://codereview.chromium.org/11144016/diff/1/lib/compiler/implementation/lib/interceptors.dart#newcode367 lib/compiler/implementation/lib/interceptors.dart:367: sort$1(receiver, compare) { Why can't you have just one ...
8 years, 2 months ago (2012-10-15 14:17:11 UTC) #3
sra1
I would suggest that also passing a key would be more versatile: http://code.google.com/p/dart/issues/detail?id=1235#c1
8 years, 2 months ago (2012-10-16 05:58:04 UTC) #4
Lasse Reichstein Nielsen
8 years, 2 months ago (2012-10-17 07:37:28 UTC) #5
Deciding how to sort should be done by the comparator function, not the sort
function. The sort function has no notion of "key".

https://codereview.chromium.org/11144016/diff/1/lib/compiler/implementation/l...
File lib/compiler/implementation/lib/interceptors.dart (right):

https://codereview.chromium.org/11144016/diff/1/lib/compiler/implementation/l...
lib/compiler/implementation/lib/interceptors.dart:367: sort$1(receiver, compare)
{
I don't think it works with how we handle receivers (it was my first attempt,
and q.v. lastIndexOf). I have no idea how easy it is to fix. I'll add a TODO for
you.

We really should be doing interceptors differently, preferably by generating
dispatch methods from the individual specialized methods, to avoid duplicated
code (and to make method extraction work for all methods).

https://codereview.chromium.org/11144016/diff/1/tests/corelib/list_sort_test....
File tests/corelib/list_sort_test.dart (right):

https://codereview.chromium.org/11144016/diff/1/tests/corelib/list_sort_test....
tests/corelib/list_sort_test.dart:14: new SortHelper((list)=>list.sort(),
compare).run();
Done.

Powered by Google App Engine
This is Rietveld 408576698