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

Side by Side Diff: src/array.js

Issue 8888006: Make more JS files beter match the coding standard. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years 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
« no previous file with comments | « no previous file | src/d8.js » ('j') | test/mjsunit/arguments-read-and-assignment.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
Kevin Millikin (Chromium) 2011/12/08 11:20:51 Here and elsewhere 2011.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution. 11 // with the distribution.
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 // For short (length <= 22) arrays, insertion sort is used for efficiency. 744 // For short (length <= 22) arrays, insertion sort is used for efficiency.
745 745
746 if (!IS_SPEC_FUNCTION(comparefn)) { 746 if (!IS_SPEC_FUNCTION(comparefn)) {
747 comparefn = function (x, y) { 747 comparefn = function (x, y) {
748 if (x === y) return 0; 748 if (x === y) return 0;
749 if (%_IsSmi(x) && %_IsSmi(y)) { 749 if (%_IsSmi(x) && %_IsSmi(y)) {
750 return %SmiLexicographicCompare(x, y); 750 return %SmiLexicographicCompare(x, y);
751 } 751 }
752 x = ToString(x); 752 x = ToString(x);
753 y = ToString(y); 753 y = ToString(y);
754 if (x == y) return 0; 754 if (x == y) {
755 else return x < y ? -1 : 1; 755 return 0;
756 } else {
757 return x < y ? -1 : 1;
758 }
756 }; 759 };
757 } 760 }
758 var receiver = %GetDefaultReceiver(comparefn); 761 var receiver = %GetDefaultReceiver(comparefn);
759 762
760 function InsertionSort(a, from, to) { 763 function InsertionSort(a, from, to) {
761 for (var i = from + 1; i < to; i++) { 764 for (var i = from + 1; i < to; i++) {
762 var element = a[i]; 765 var element = a[i];
763 for (var j = i - 1; j >= from; j--) { 766 for (var j = i - 1; j >= from; j--) {
764 var tmp = a[j]; 767 var tmp = a[j];
765 var order = %_CallFunction(receiver, tmp, element, comparefn); 768 var order = %_CallFunction(receiver, tmp, element, comparefn);
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 1232
1230 var length = TO_UINT32(this.length); 1233 var length = TO_UINT32(this.length);
1231 if (length == 0) return -1; 1234 if (length == 0) return -1;
1232 if (%_ArgumentsLength() < 2) { 1235 if (%_ArgumentsLength() < 2) {
1233 index = length - 1; 1236 index = length - 1;
1234 } else { 1237 } else {
1235 index = TO_INTEGER(index); 1238 index = TO_INTEGER(index);
1236 // If index is negative, index from end of the array. 1239 // If index is negative, index from end of the array.
1237 if (index < 0) index += length; 1240 if (index < 0) index += length;
1238 // If index is still negative, do not search the array. 1241 // If index is still negative, do not search the array.
1239 if (index < 0) return -1; 1242 if (index < 0) {
1240 else if (index >= length) index = length - 1; 1243 return -1;
1244 } else if (index >= length) {
1245 index = length - 1;
1246 }
1241 } 1247 }
1242 var min = 0; 1248 var min = 0;
1243 var max = index; 1249 var max = index;
1244 if (UseSparseVariant(this, length, IS_ARRAY(this))) { 1250 if (UseSparseVariant(this, length, IS_ARRAY(this))) {
1245 var intervals = %GetArrayKeys(this, index + 1); 1251 var intervals = %GetArrayKeys(this, index + 1);
1246 if (intervals.length == 2 && intervals[0] < 0) { 1252 if (intervals.length == 2 && intervals[0] < 0) {
1247 // A single interval. 1253 // A single interval.
1248 var intervalMin = -(intervals[0] + 1); 1254 var intervalMin = -(intervals[0] + 1);
1249 var intervalMax = intervalMin + intervals[1]; 1255 var intervalMax = intervalMin + intervals[1];
1250 if (min < intervalMin) min = intervalMin; 1256 if (min < intervalMin) min = intervalMin;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 // exposed to user code. 1424 // exposed to user code.
1419 // Adding only the functions that are actually used. 1425 // Adding only the functions that are actually used.
1420 SetUpLockedPrototype(InternalArray, $Array(), $Array( 1426 SetUpLockedPrototype(InternalArray, $Array(), $Array(
1421 "join", getFunction("join", ArrayJoin), 1427 "join", getFunction("join", ArrayJoin),
1422 "pop", getFunction("pop", ArrayPop), 1428 "pop", getFunction("pop", ArrayPop),
1423 "push", getFunction("push", ArrayPush) 1429 "push", getFunction("push", ArrayPush)
1424 )); 1430 ));
1425 } 1431 }
1426 1432
1427 SetUpArray(); 1433 SetUpArray();
OLDNEW
« no previous file with comments | « no previous file | src/d8.js » ('j') | test/mjsunit/arguments-read-and-assignment.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698