]> zoso.dev Git - buffer.git/commitdiff
small perf improvement
authorFeross Aboukhadijeh <feross@feross.org>
Thu, 11 Feb 2021 03:32:36 +0000 (19:32 -0800)
committerFeross Aboukhadijeh <feross@feross.org>
Thu, 11 Feb 2021 03:32:36 +0000 (19:32 -0800)
index.js

index 7a0e9c2a123bc9d26c20bb3de4a3c4e49b24ee40..cc1992621cf0db058930ff1a7110c21fdcd3e6a3 100644 (file)
--- a/index.js
+++ b/index.js
@@ -410,7 +410,9 @@ Buffer.concat = function concat (list, length) {
     let buf = list[i]
     if (isInstance(buf, Uint8Array)) {
       if (pos + buf.length > buffer.length) {
-        if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf)
+        if (!Buffer.isBuffer(buf)) {
+          buf = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)
+        }
         buf.copy(buffer, pos)
       } else {
         Uint8Array.prototype.set.call(