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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: dart/lib/compiler/implementation/lib/interceptors.dart
diff --git a/dart/lib/compiler/implementation/lib/interceptors.dart b/dart/lib/compiler/implementation/lib/interceptors.dart
index 680af43e4408e4c86110e683b17e77d774d02123..d958422d3774bf7f2d2b016c1d7ed4ed1e80f5fd 100644
--- a/dart/lib/compiler/implementation/lib/interceptors.dart
+++ b/dart/lib/compiler/implementation/lib/interceptors.dart
@@ -364,13 +364,16 @@ every(receiver, f) {
sort$0(receiver) {
if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.sort());
checkMutable(receiver, 'sort');
- DualPivotQuicksort.sort(receiver, Comparable.compare);
+ 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.
}
sort$1(receiver, compare) {
if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.sort(compare));
checkMutable(receiver, 'sort');
- DualPivotQuicksort.sort(receiver, compare);
+ 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.
+ ' 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.
+ DART_CLOSURE_TO_JS(compareHelper), compare);
+ 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.
}
isNegative(receiver) {

Powered by Google App Engine
This is Rietveld 408576698