Skip to content

Commit 2ac258c

Browse files
cesco69bjohansebas
authored andcommitted
perf: 2x faster hash stringify
1 parent 976b3f7 commit 2ac258c

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

index.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -553,14 +553,8 @@ function getcookie(req, name, secrets) {
553553

554554
function hash(sess) {
555555
// serialize
556-
var str = JSON.stringify(sess, function (key, val) {
557-
// ignore sess.cookie property
558-
if (this === sess && key === 'cookie') {
559-
return
560-
}
561-
562-
return val
563-
})
556+
const { cookie, ...sessWithoutCookie } = sess;
557+
const str = JSON.stringify(sessWithoutCookie);
564558

565559
// hash
566560
return crypto

0 commit comments

Comments
 (0)