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

Side by Side Diff: src/harmony-array.js

Issue 1345333002: src: Use simple/fast macro version of MinMax in JS (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Back from beginInt to startInt Created 5 years, 3 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
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function(global, utils) { 5 (function(global, utils) {
6 6
7 'use strict'; 7 'use strict';
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
11 // ------------------------------------------------------------------- 11 // -------------------------------------------------------------------
12 // Imports 12 // Imports
13 13
14 var GetIterator; 14 var GetIterator;
15 var GetMethod; 15 var GetMethod;
16 var GlobalArray = global.Array; 16 var GlobalArray = global.Array;
17 var iteratorSymbol = utils.ImportNow("iterator_symbol"); 17 var iteratorSymbol = utils.ImportNow("iterator_symbol");
18 var MathMax;
19 var MathMin;
20 var ObjectIsFrozen; 18 var ObjectIsFrozen;
21 var ObjectDefineProperty; 19 var ObjectDefineProperty;
22 var ToNumber; 20 var ToNumber;
23 21
24 utils.Import(function(from) { 22 utils.Import(function(from) {
25 GetIterator = from.GetIterator; 23 GetIterator = from.GetIterator;
26 GetMethod = from.GetMethod; 24 GetMethod = from.GetMethod;
27 MathMax = from.MathMax;
28 MathMin = from.MathMin;
29 ObjectIsFrozen = from.ObjectIsFrozen; 25 ObjectIsFrozen = from.ObjectIsFrozen;
30 ObjectDefineProperty = from.ObjectDefineProperty; 26 ObjectDefineProperty = from.ObjectDefineProperty;
31 ToNumber = from.ToNumber; 27 ToNumber = from.ToNumber;
32 }); 28 });
33 29
34 // ------------------------------------------------------------------- 30 // -------------------------------------------------------------------
35 31
36 function InnerArrayCopyWithin(target, start, end, array, length) { 32 function InnerArrayCopyWithin(target, start, end, array, length) {
37 target = TO_INTEGER(target); 33 target = TO_INTEGER(target);
38 var to; 34 var to;
39 if (target < 0) { 35 if (target < 0) {
40 to = MathMax(length + target, 0); 36 to = MAX_SIMPLE(length + target, 0);
41 } else { 37 } else {
42 to = MathMin(target, length); 38 to = MIN_SIMPLE(target, length);
43 } 39 }
44 40
45 start = TO_INTEGER(start); 41 start = TO_INTEGER(start);
46 var from; 42 var from;
47 if (start < 0) { 43 if (start < 0) {
48 from = MathMax(length + start, 0); 44 from = MAX_SIMPLE(length + start, 0);
49 } else { 45 } else {
50 from = MathMin(start, length); 46 from = MIN_SIMPLE(start, length);
51 } 47 }
52 48
53 end = IS_UNDEFINED(end) ? length : TO_INTEGER(end); 49 end = IS_UNDEFINED(end) ? length : TO_INTEGER(end);
54 var final; 50 var final;
55 if (end < 0) { 51 if (end < 0) {
56 final = MathMax(length + end, 0); 52 final = MAX_SIMPLE(length + end, 0);
57 } else { 53 } else {
58 final = MathMin(end, length); 54 final = MIN_SIMPLE(end, length);
59 } 55 }
60 56
61 var count = MathMin(final - from, length - to); 57 var count = MIN_SIMPLE(final - from, length - to);
62 var direction = 1; 58 var direction = 1;
63 if (from < to && to < (from + count)) { 59 if (from < to && to < (from + count)) {
64 direction = -1; 60 direction = -1;
65 from = from + count - 1; 61 from = from + count - 1;
66 to = to + count - 1; 62 to = to + count - 1;
67 } 63 }
68 64
69 while (count > 0) { 65 while (count > 0) {
70 if (from in array) { 66 if (from in array) {
71 array[to] = array[from]; 67 array[to] = array[from];
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 287
292 utils.Export(function(to) { 288 utils.Export(function(to) {
293 to.ArrayFrom = ArrayFrom; 289 to.ArrayFrom = ArrayFrom;
294 to.InnerArrayCopyWithin = InnerArrayCopyWithin; 290 to.InnerArrayCopyWithin = InnerArrayCopyWithin;
295 to.InnerArrayFill = InnerArrayFill; 291 to.InnerArrayFill = InnerArrayFill;
296 to.InnerArrayFind = InnerArrayFind; 292 to.InnerArrayFind = InnerArrayFind;
297 to.InnerArrayFindIndex = InnerArrayFindIndex; 293 to.InnerArrayFindIndex = InnerArrayFindIndex;
298 }); 294 });
299 295
300 }) 296 })
OLDNEW
« src/arraybuffer.js ('K') | « src/arraybuffer.js ('k') | src/harmony-atomics.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698