From 4057b5f4b99b2417a9ebc4363d65dc2e4c268b27 Mon Sep 17 00:00:00 2001 From: sasm Date: Mon, 2 Apr 2018 09:44:33 -0700 Subject: [PATCH 1/2] fixed mem issues when generating uuid --- lib/bytesToUuid.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/bytesToUuid.js b/lib/bytesToUuid.js index 2c9a2230..990c70bc 100644 --- a/lib/bytesToUuid.js +++ b/lib/bytesToUuid.js @@ -10,14 +10,14 @@ for (var i = 0; i < 256; ++i) { function bytesToUuid(buf, offset) { var i = offset || 0; var bth = byteToHex; - return bth[buf[i++]] + bth[buf[i++]] + - bth[buf[i++]] + bth[buf[i++]] + '-' + - bth[buf[i++]] + bth[buf[i++]] + '-' + - bth[buf[i++]] + bth[buf[i++]] + '-' + - bth[buf[i++]] + bth[buf[i++]] + '-' + - bth[buf[i++]] + bth[buf[i++]] + - bth[buf[i++]] + bth[buf[i++]] + - bth[buf[i++]] + bth[buf[i++]]; + return ([bth[buf[i++]], bth[buf[i++]], + bth[buf[i++]], bth[buf[i++]], '-', + bth[buf[i++]], bth[buf[i++]], '-', + bth[buf[i++]], bth[buf[i++]], '-', + bth[buf[i++]], bth[buf[i++]], '-', + bth[buf[i++]], bth[buf[i++]], + bth[buf[i++]], bth[buf[i++]], + bth[buf[i++]], bth[buf[i++]]]).join(''); } module.exports = bytesToUuid; From e39ae19278d4bf33b0acb587504fd94d6bdc6ddd Mon Sep 17 00:00:00 2001 From: sasm Date: Tue, 3 Apr 2018 08:21:42 -0700 Subject: [PATCH 2/2] updated comment on memory issue --- lib/bytesToUuid.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/bytesToUuid.js b/lib/bytesToUuid.js index 990c70bc..847c4828 100644 --- a/lib/bytesToUuid.js +++ b/lib/bytesToUuid.js @@ -10,6 +10,7 @@ for (var i = 0; i < 256; ++i) { function bytesToUuid(buf, offset) { var i = offset || 0; var bth = byteToHex; + // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4 return ([bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], '-',