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

Unified Diff: src/typedarray.js

Issue 1331993004: [es6] Optimize TypedArray.subarray() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove unused references 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 side-by-side diff with in-line comments
Download patch
« src/macros.py ('K') | « src/macros.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/typedarray.js
diff --git a/src/typedarray.js b/src/typedarray.js
index 81fc13ea567b3752b47dd7a0fb4916b60690809c..09bf7f60b0c74d4eed1376f596cb3f8ec27a8981 100644
--- a/src/typedarray.js
+++ b/src/typedarray.js
@@ -37,13 +37,9 @@ endmacro
TYPED_ARRAYS(DECLARE_GLOBALS)
-var MathMax;
-var MathMin;
var ToNumber;
utils.Import(function(from) {
- MathMax = from.MathMax;
- MathMin = from.MathMin;
ToNumber = from.ToNumber;
});
@@ -210,25 +206,29 @@ function NAMESubArray(begin, end) {
}
var beginInt = TO_INTEGER(begin);
if (!IS_UNDEFINED(end)) {
- end = TO_INTEGER(end);
+ var endInt = TO_INTEGER(end);
+ var srcLength = %_TypedArrayGetLength(this);
+ } else {
+ var srcLength = %_TypedArrayGetLength(this);
+ var endInt = srcLength;
}
- var srcLength = %_TypedArrayGetLength(this);
if (beginInt < 0) {
- beginInt = MathMax(0, srcLength + beginInt);
+ beginInt = MAX_SIMPLE(0, srcLength + beginInt);
} else {
- beginInt = MathMin(srcLength, beginInt);
+ beginInt = MIN_SIMPLE(beginInt, srcLength);
}
- var endInt = IS_UNDEFINED(end) ? srcLength : end;
if (endInt < 0) {
- endInt = MathMax(0, srcLength + endInt);
+ endInt = MAX_SIMPLE(0, srcLength + endInt);
} else {
- endInt = MathMin(endInt, srcLength);
+ endInt = MIN_SIMPLE(endInt, srcLength);
}
+
if (endInt < beginInt) {
endInt = beginInt;
}
+
var newLength = endInt - beginInt;
var beginByteOffset =
%_ArrayBufferViewGetByteOffset(this) + beginInt * ELEMENT_SIZE;
« src/macros.py ('K') | « src/macros.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698