Index: src/arraybuffer.js |
diff --git a/src/arraybuffer.js b/src/arraybuffer.js |
index 0db0c2bf046477840fc0f97a48c43d9aacaa058a..6d080dcc49b063376b90246f2198f9e656059c54 100644 |
--- a/src/arraybuffer.js |
+++ b/src/arraybuffer.js |
@@ -13,14 +13,10 @@ |
var GlobalArrayBuffer = global.ArrayBuffer; |
var GlobalObject = global.Object; |
-var MathMax; |
-var MathMin; |
var ToNumber; |
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); |
utils.Import(function(from) { |
- MathMax = from.MathMax; |
- MathMin = from.MathMin; |
ToNumber = from.ToNumber; |
}); |
@@ -50,33 +46,36 @@ function ArrayBufferSlice(start, end) { |
'ArrayBuffer.prototype.slice', this); |
} |
- var relativeStart = TO_INTEGER(start); |
+ var startInt = TO_INTEGER(start); |
if (!IS_UNDEFINED(end)) { |
- end = TO_INTEGER(end); |
+ var endInt = TO_INTEGER(end); |
+ var byteLength = %_ArrayBufferGetByteLength(this); |
+ } else { |
+ var byteLength = %_ArrayBufferGetByteLength(this); |
Dan Ehrenberg
2015/09/16 21:34:21
Why did you move this inside of the conditional ra
skomski
2015/09/16 21:57:39
Same code as in SubArray; related to https://coder
Jakob Kummerow
2015/09/17 07:36:34
That's not a good reason. It didn't make sense the
skomski
2015/09/17 08:07:03
First one was not a reason rather I thought he mis
|
+ var endInt = byteLength; |
} |
- var first; |
- var byte_length = %_ArrayBufferGetByteLength(this); |
- if (relativeStart < 0) { |
- first = MathMax(byte_length + relativeStart, 0); |
+ |
+ if (startInt < 0) { |
+ startInt = MAX_SIMPLE(byteLength + startInt, 0); |
} else { |
- first = MathMin(relativeStart, byte_length); |
+ startInt = MIN_SIMPLE(startInt, byteLength); |
} |
- var relativeEnd = IS_UNDEFINED(end) ? byte_length : end; |
- var fin; |
- if (relativeEnd < 0) { |
- fin = MathMax(byte_length + relativeEnd, 0); |
+ |
+ if (endInt < 0) { |
+ endInt = MAX_SIMPLE(byteLength + endInt, 0); |
} else { |
- fin = MathMin(relativeEnd, byte_length); |
+ endInt = MIN_SIMPLE(endInt, byteLength); |
} |
- if (fin < first) { |
- fin = first; |
+ if (endInt < startInt) { |
+ endInt = startInt; |
} |
- var newLen = fin - first; |
+ |
+ var newLength = endInt - startInt; |
// TODO(dslomov): implement inheritance |
- var result = new GlobalArrayBuffer(newLen); |
+ var result = new GlobalArrayBuffer(newLength); |
- %ArrayBufferSliceImpl(this, result, first); |
+ %ArrayBufferSliceImpl(this, result, startInt); |
return result; |
} |