From 2ac258c48948b592ef7597625c43abd7cbb683db Mon Sep 17 00:00:00 2001 From: francesco Date: Mon, 14 Apr 2025 15:33:48 +0200 Subject: [PATCH] perf: 2x faster hash stringify --- index.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index e7cc383f..d57bf8a2 100644 --- a/index.js +++ b/index.js @@ -553,14 +553,8 @@ function getcookie(req, name, secrets) { function hash(sess) { // serialize - var str = JSON.stringify(sess, function (key, val) { - // ignore sess.cookie property - if (this === sess && key === 'cookie') { - return - } - - return val - }) + const { cookie, ...sessWithoutCookie } = sess; + const str = JSON.stringify(sessWithoutCookie); // hash return crypto