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

Side by Side Diff: dart/lib/compiler/implementation/lib/interceptors.dart

Issue 11193032: Use JavaScript's Array.sort. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #library('dart:_interceptors'); 5 #library('dart:_interceptors');
6 6
7 #import('dart:coreimpl'); 7 #import('dart:coreimpl');
8 8
9 add$1(var receiver, var value) { 9 add$1(var receiver, var value) {
10 if (isJsArray(receiver)) { 10 if (isJsArray(receiver)) {
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 return Collections.every(receiver, f); 357 return Collections.every(receiver, f);
358 } 358 }
359 } 359 }
360 360
361 // TODO(ngeoffray): Make it possible to have just one "sort" function ends 361 // TODO(ngeoffray): Make it possible to have just one "sort" function ends
362 // an optional parameter. 362 // an optional parameter.
363 363
364 sort$0(receiver) { 364 sort$0(receiver) {
365 if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.sort()); 365 if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.sort());
366 checkMutable(receiver, 'sort'); 366 checkMutable(receiver, 'sort');
367 DualPivotQuicksort.sort(receiver, Comparable.compare); 367 JS('var', '#.sort(#)', receiver, DART_CLOSURE_TO_JS(Comparable.compare));
kasperl 2012/10/18 07:46:36 'var' -> 'void'?
ahe 2012/10/18 10:37:36 Done.
368 } 368 }
369 369
370 sort$1(receiver, compare) { 370 sort$1(receiver, compare) {
371 if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.sort(compare)); 371 if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.sort(compare));
372 checkMutable(receiver, 'sort'); 372 checkMutable(receiver, 'sort');
373 DualPivotQuicksort.sort(receiver, compare); 373 var jsCompare = JS('var', '(function (compareHelper, compare) {'
sra1 2012/10/18 07:44:39 A few linebreaks might improve the indentation, e.
ahe 2012/10/18 10:37:36 Using bind instead.
374 ' return function (a, b) { return compareHelper(compare, a, b); } })(#, #)',
sra1 2012/10/18 07:44:39 sort calls function (a, b), which calls the functi
kasperl 2012/10/18 07:46:36 Fix long line with a bit more adjacent string conc
ahe 2012/10/18 10:37:36 You are correct. I have used tests/co19/src/LibTe
ahe 2012/10/18 10:37:36 Using bind which is shorter.
375 DART_CLOSURE_TO_JS(compareHelper), compare);
376 JS('var', '#.sort(#)', receiver, jsCompare);
kasperl 2012/10/18 07:46:36 'var' -> 'void'?
Lasse Reichstein Nielsen 2012/10/18 08:23:28 JavaScript's sort is hard-coded to sort null/undef
ahe 2012/10/18 10:37:36 Done.
ahe 2012/10/18 10:37:36 Done.
374 } 377 }
375 378
376 isNegative(receiver) { 379 isNegative(receiver) {
377 if (receiver is num) { 380 if (receiver is num) {
378 return (receiver == 0) ? (1 / receiver) < 0 : receiver < 0; 381 return (receiver == 0) ? (1 / receiver) < 0 : receiver < 0;
379 } else { 382 } else {
380 return UNINTERCEPTED(receiver.isNegative()); 383 return UNINTERCEPTED(receiver.isNegative());
381 } 384 }
382 } 385 }
383 386
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 } else { 680 } else {
678 return UNINTERCEPTED(receiver.runtimeType); 681 return UNINTERCEPTED(receiver.runtimeType);
679 } 682 }
680 } 683 }
681 684
682 // TODO(lrn): These getters should be generated automatically for all 685 // TODO(lrn): These getters should be generated automatically for all
683 // intercepted methods. 686 // intercepted methods.
684 get$toString(receiver) => () => toString(receiver); 687 get$toString(receiver) => () => toString(receiver);
685 688
686 get$hashCode(receiver) => () => hashCode(receiver); 689 get$hashCode(receiver) => () => hashCode(receiver);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698