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-15 02:06:09 +00:00
committed by Copybot
parent 2293713e96
commit a06031425b
+1 -1
View File
@@ -415,7 +415,7 @@ function processPdfRequest(
if (offsetStart > 0 || offsetEnd > 0) {
// compute index positions for slice to handle case where offsetEnd=0
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)
reAssembledBlob.set(data, insertPosition)