diff options
author | Luca Casonato <hello@lcas.dev> | 2024-08-02 16:23:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-02 16:23:21 +0200 |
commit | 7495bcbf77349d708b249944a149c16f5ee0c667 (patch) | |
tree | d6b1250478c1d3b5b4670bfb8e90debf841a4bbc /ext/node/polyfills/string_decoder.ts | |
parent | e24aa6bbeca265454fea3592fc9fc18e6312556e (diff) |
Revert "perf(ext/node): improve `Buffer` from string performance" (#24851)
Diffstat (limited to 'ext/node/polyfills/string_decoder.ts')
-rw-r--r-- | ext/node/polyfills/string_decoder.ts | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/ext/node/polyfills/string_decoder.ts b/ext/node/polyfills/string_decoder.ts index 19aff8124..4a49c2e3e 100644 --- a/ext/node/polyfills/string_decoder.ts +++ b/ext/node/polyfills/string_decoder.ts @@ -39,15 +39,10 @@ const { Symbol, MathMin, DataViewPrototypeGetBuffer, - DataViewPrototypeGetByteLength, - DataViewPrototypeGetByteOffset, ObjectPrototypeIsPrototypeOf, String, TypedArrayPrototypeGetBuffer, - TypedArrayPrototypeGetByteLength, - TypedArrayPrototypeGetByteOffset, StringPrototypeToLowerCase, - Uint8Array, } = primordials; const { isTypedArray } = core; @@ -88,21 +83,11 @@ function normalizeBuffer(buf: Buffer) { } if (isBufferType(buf)) { return buf; - } else if (isTypedArray(buf)) { - return Buffer.from( - new Uint8Array( - TypedArrayPrototypeGetBuffer(buf), - TypedArrayPrototypeGetByteOffset(buf), - TypedArrayPrototypeGetByteLength(buf), - ), - ); } else { return Buffer.from( - new Uint8Array( - DataViewPrototypeGetBuffer(buf), - DataViewPrototypeGetByteOffset(buf), - DataViewPrototypeGetByteLength(buf), - ), + isTypedArray(buf) + ? TypedArrayPrototypeGetBuffer(buf) + : DataViewPrototypeGetBuffer(buf), ); } } |