Skip to content

Commit

Permalink
Revert "perf: improve Buffer.from(buf) by 29x" (denoland#24351)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored and sbmsr committed Jul 2, 2024
1 parent 025b4c6 commit 36fd4a9
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions ext/node/polyfills/internal/buffer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 36fd4a9

Please sign in to comment.