Remove bufferClone fork.

This commit is contained in:
jdalton
2015-05-26 11:22:06 -07:00
parent 255da0a0d7
commit ae0bb54b2d

View File

@@ -761,7 +761,6 @@
/** Native method references. */ /** Native method references. */
var ArrayBuffer = getNative(context, 'ArrayBuffer'), var ArrayBuffer = getNative(context, 'ArrayBuffer'),
bufferSlice = getNative(ArrayBuffer && new ArrayBuffer(0), 'slice'),
ceil = Math.ceil, ceil = Math.ceil,
clearTimeout = context.clearTimeout, clearTimeout = context.clearTimeout,
floor = Math.floor, floor = Math.floor,
@@ -3030,28 +3029,22 @@
* @param {ArrayBuffer} buffer The array buffer to clone. * @param {ArrayBuffer} buffer The array buffer to clone.
* @returns {ArrayBuffer} Returns the cloned array buffer. * @returns {ArrayBuffer} Returns the cloned array buffer.
*/ */
function bufferClone(buffer) { var bufferClone = !(ArrayBuffer && Uint8Array) ? constant(null) : function(buffer) {
return bufferSlice.call(buffer, 0); var byteLength = buffer.byteLength,
} floatLength = Float64Array ? floor(byteLength / FLOAT64_BYTES_PER_ELEMENT) : 0,
if (!bufferSlice) { offset = floatLength * FLOAT64_BYTES_PER_ELEMENT,
// PhantomJS has `ArrayBuffer` and `Uint8Array` but not `Float64Array`. result = new ArrayBuffer(byteLength);
bufferClone = !(ArrayBuffer && Uint8Array) ? constant(null) : function(buffer) {
var byteLength = buffer.byteLength,
floatLength = Float64Array ? floor(byteLength / FLOAT64_BYTES_PER_ELEMENT) : 0,
offset = floatLength * FLOAT64_BYTES_PER_ELEMENT,
result = new ArrayBuffer(byteLength);
if (floatLength) { if (floatLength) {
var view = new Float64Array(result, 0, floatLength); var view = new Float64Array(result, 0, floatLength);
view.set(new Float64Array(buffer, 0, floatLength)); view.set(new Float64Array(buffer, 0, floatLength));
} }
if (byteLength != offset) { if (byteLength != offset) {
view = new Uint8Array(result, offset); view = new Uint8Array(result, offset);
view.set(new Uint8Array(buffer, offset)); view.set(new Uint8Array(buffer, offset));
} }
return result; return result;
}; };
}
/** /**
* Creates an array that is the composition of partially applied arguments, * Creates an array that is the composition of partially applied arguments,