From 24d2cf426fef23e268b89ee0cf9d2923bf92dd02 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Thu, 23 Mar 2023 14:23:06 +0000 Subject: [PATCH] Merge pull request #12368 from overleaf/jlm-jpa-switch-to-json-parse-from-bytes [docstore] potential optimization for parsing a large JSON from buffer GitOrigin-RevId: 1c2fb82eb27e2f5d58f75b99fab5dffc2d9b51d0 --- services/docstore/app/js/DocArchiveManager.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/services/docstore/app/js/DocArchiveManager.js b/services/docstore/app/js/DocArchiveManager.js index dcddef41f4..c0888f249b 100644 --- a/services/docstore/app/js/DocArchiveManager.js +++ b/services/docstore/app/js/DocArchiveManager.js @@ -136,8 +136,7 @@ async function getDoc(projectId, docId) { }) } - const json = buffer.toString() - return _deserializeArchivedDoc(json) + return _deserializeArchivedDoc(buffer) } // get the doc and unarchive it to mongo @@ -199,8 +198,8 @@ async function _streamToBuffer(projectId, docId, stream) { }) } -function _deserializeArchivedDoc(json) { - const doc = JSON.parse(json) +function _deserializeArchivedDoc(buffer) { + const doc = JSON.parse(buffer) const result = {} if (doc.schema_v === 1 && doc.lines != null) {