Merge pull request #4183 from overleaf/jpa-use-memory-views

[perf] serviceWorker: use memory view on large chunks instead of slicing

GitOrigin-RevId: 10933b25500aebc0b236315aceca4c44089c79e6
This commit is contained in:
Jakob Ackermann 2021-06-14 10:11:29 +02:00 committed by Copybot
parent 2293713e96
commit a06031425b

View file

@ -415,7 +415,7 @@ function processPdfRequest(
if (offsetStart > 0 || offsetEnd > 0) { if (offsetStart > 0 || offsetEnd > 0) {
// compute index positions for slice to handle case where offsetEnd=0 // compute index positions for slice to handle case where offsetEnd=0
const chunkSize = chunk.end - chunk.start const chunkSize = chunk.end - chunk.start
data = data.slice(offsetStart, chunkSize - offsetEnd) data = data.subarray(offsetStart, chunkSize - offsetEnd)
} }
const insertPosition = Math.max(chunk.start - start, 0) const insertPosition = Math.max(chunk.start - start, 0)
reAssembledBlob.set(data, insertPosition) reAssembledBlob.set(data, insertPosition)