summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-06-26 16:23:09 -0400
committerGitHub <noreply@github.com>2024-06-26 16:23:09 -0400
commit77ba0019e73710e1e685a8051b9cca79cc6e5054 (patch)
tree423598bf9c98e4fc3643e5936a34a350dea8a6fd
parent2549e5154ceaa8246b328f204abf8d63a68d0c25 (diff)
Revert "perf: improve Buffer.from(buf) by 29x" (#24351)
https://github.com/denoland/deno/pull/24341#discussion_r1655247367 Reverts denoland/deno#24341
-rw-r--r--ext/node/polyfills/internal/buffer.mjs11
1 files changed, 0 insertions, 11 deletions
diff --git a/ext/node/polyfills/internal/buffer.mjs b/ext/node/polyfills/internal/buffer.mjs
index de3568a83..a051965a3 100644
--- a/ext/node/polyfills/internal/buffer.mjs
+++ b/ext/node/polyfills/internal/buffer.mjs
@@ -229,22 +229,11 @@ function fromArrayLike(array) {
return buf;
}
-function fromUint8Array(u8) {
- const buf = new Uint8Array(u8.buffer, u8.byteOffset, u8.byteLength);
- Object.setPrototypeOf(buf, Buffer.prototype);
- return buf.slice();
-}
-
function fromObject(obj) {
if (obj.length !== undefined || isAnyArrayBuffer(obj.buffer)) {
if (typeof obj.length !== "number") {
return createBuffer(0);
}
-
- if (obj instanceof Uint8Array) {
- return fromUint8Array(obj);
- }
-
return fromArrayLike(obj);
}